[Javascript] multiple ifs on one line syntax

Dan Costea costea.dan at ssi-schaefer.ro
Thu Jun 6 18:54:36 CDT 2002


try:

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') ){ ... }

Dan.


----- Original Message -----
From: "Andrew Peterson" <webmaster at mail.ioc.state.il.us>
To: <javascript at LaTech.edu>
Sent: Thursday, June 06, 2002 6:48 AM
Subject: [Javascript] multiple ifs on one line syntax


> Hi,
>
> 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') {
> ...
>
> Any help greatly appreciated.
>
> Thanks in advance,
> Andrew
>
>
> > -----Original Message-----
> > From: javascript-admin at LaTech.edu
> > [mailto:javascript-admin at LaTech.edu]On
> > Behalf Of Rodney Myers
> > Sent: Friday, May 03, 2002 3:07 AM
> > To: javascript at LaTech.edu
> > Subject: Re: [Javascript] "Object Expected" Error
> >
> >
> > Try
> > if (string.indexOf("<TEXTAREA")>-1)
> >
> > Your current expression
> > string.indexOf("<TEXTAREA")
> > gives the value -1 because there is no "<TEXTAREA"
> > -1 is TRUE not FALSE!
> > Only 0 is false.
> >
> > hth
> >
> > Rodney
> >
> >
> > SoitPP at aol.com wrote:
> >
> > > Dear JavaScript list,
> > > I am getting an "Object Expected" Error when trying to
> > > call a certain function in a program. I don't quite understand
> > > what is causing this error. The program flow seems simple enough.
> > > What am I missing?
> > > Here is a duplication of the error in a cut down version:
> > >
> > > <html>
> > > <head>
> > > <title>Function Testing</title>
> > > <script language="JavaScript">
> > > function removeValue(string) {
> > > if (string.indexOf("<TEXTAREA")) {
> > > //line 17 follows
> > > string = string.substring(0,indexOf("<TEXTAREA")) +
> > > string.substring(indexOf("</TEXTAREA>",string.length))
> > > return string
> > > }
> > > return string
> > > }
> > > function robot() {
> > > preSTRvariable = document.body.innerHTML
> > > preSTRvariable = removeValue(preSTRvariable)
> > > }
> > > </script>
> > > </head>
> > > <body>
> > > <form>
> > > <button style="background-color: #FFFFFF" onClick="robot
> > > ()">Click</button>
> > > </form>
> > > </body>
> > > </html>
> > >
> > > Very simple right? So how come I get "Objected Expected" at line 17?
> > > Patiently,
> > > Aaron
> > >
> > >
> > > _______________________________________________
> > > Javascript mailing list
> > > Javascript at LaTech.edu
> > > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list