[Javascript] multiple ifs on one line syntax

Mckinney, Lori K lkmckinn at ingr.com
Thu Jun 6 08:53:23 CDT 2002


Use && for AND and || for OR

if(form.TransType.options[form.TransType.selectedIndex].value == 'S' && form.RecipientAgency.value=='P' )

if(form.TransType.options[form.TransType.selectedIndex].value == 'R' || form.TransType.options[form.TransType.selectedIndex].value == 'S') 

-----Original Message-----

I left my O'Reilly Javascript book at home (DOH!) and am having trouble with
the syntax for two IF statements on one line using either AND or OR to
separate them. The following statement using AND generates an error:

if(form.TransType.options[form.TransType.selectedIndex].value == 'S') and
(form.RecipientAgency.value=='P')   {
...

similarly, when I try using OR like the following example, the same problem
occurs:

if(form.TransType.options[form.TransType.selectedIndex].value == 'R') OR
(form.TransType.options[form.TransType.selectedIndex].value == 'S') {
...



More information about the Javascript mailing list