Solved

multiple conditions in 1 with '&&' ?

Posted on 2008-06-19
3
1,356 Views
Last Modified: 2013-11-19
Hi,

can somebody say me how do i make multiple conditions at once in javascript?
The code that i include shows you how i do it now, but i would like to know how to make it one 'if(...)....{}'
not 'if(...){ if(...){...} }'
if (!document.form1.parents.checked == 1)
   {    if (document.form1.gebjaar.value > "1990") {
      		alert("You have to accept the parents approval checkbox to go on");
      		return false;}
   }

Open in new window

0
Comment
Question by:behets
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:Zippit
ID: 21821107

if((!document.form1.parents.checked == 1) && (document.form1.gebjaar.value > "1990")) {
    alert("You have to accept the parents approval checkbox to go on");
    return false;
}

Open in new window

0
 
LVL 8

Expert Comment

by:Bird Dog
ID: 21821126
I have not used java in quite a while but I remember using the and (&&) operator for the same thing you are trying to do or use the or (||) operator
0
 
LVL 14

Accepted Solution

by:
ali_kayahan earned 250 total points
ID: 21821143
Or you may use shortened way like the code below basicly its logic is
 condition ? run if condition is true : run if condition is false
!document.form1.parents.checked == 1 ? alert("You have to accept the parents approval checkbox to go on") : document.form1.gebjaar.value > "1990" ? alert("You have to accept the parents approval checkbox to go on") : return false ;

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
close pop up windows when logout or main window closes 17 86
Boolean 13 51
Set css in function 11 56
Sticking text to shapes in Raphael.js 6 41
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question