writing an or statement

Results 1 to 2 of 2

Thread: writing an or statement

  1. #1
    Join Date
    Dec 1969

    Default writing an or statement

    If I have a variable that I want to do something if either of 2 conditions are met. how would I write that in JavaScript. <BR>I know in other laguages it is just something like this.<BR><BR>If (plan = &#039;GS&#039; or plan = &#039;GN&#039;) then<BR>do whatever<BR>end if<BR><BR>I tried this in Javascript and it failed. <BR>any suggestions would be appreciated.<BR><BR>Thanks,<BR><BR>Bill

  2. #2
    Join Date
    Dec 1969

    Default Well, first suggestion...

    ...would be to read the JavaScript docs. Either the Netscape ones or the MS ones. For MS, you can download them by starting at http://msdn.microsoft.com/scripting (look for "downloadable documentation" or words to the effect).<BR><BR>Anyway, you&#039;ve got several errors in your little scrap of JavaScript:<BR><BR>If (plan = &#039;GS&#039; or plan = &#039;GN&#039;) then<BR> do whatever<BR>end if<BR><BR>Everything in red there is a mistake.<BR><BR>Corrected:<BR><BR>if ( plan == &#039;GS&#039; &#124&#124 plan == &#039;GN&#039; )<BR>{<BR> ... do whatever ...<BR>}<BR><BR>So see what I mean? If you are that far off, it will take you weeks to write a small JS script. Better to take the time *now* to learn some of the fundamentals. <BR><BR>Oh...and another good resource is the JavaScript FAQ at http://www.irt.org<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts