Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with != && != 2

Status
Not open for further replies.

smashing

Programmer
Oct 15, 2002
170
US
This is the condition:

if (firstform.outmonth.value !="12" && firstform.retmonth.value !="01") {

Coming from a PHP envoirement, why can I not get it in Javascript be evaluated in whole? ie to return true both conditions have to be met.
 
What is your problem? Are you getting an error in your page, or is it just not producing the results you're expecting?

-kaht

banghead.gif
 
it just not producing the results I'm expecting.
Its evaluating each part separately. ie if firstform.outmonth.value !="12" then it does'nt care what the value of firstform.retmonth is
 
this shouldn't matter.... but try encapsulating each if clause inside ()'s like so:

Code:
if ((firstform.outmonth.value != "12") && (firstform.retmonth.value != "01"))

-kaht

banghead.gif
 
Might just be your logic:
[tt]
if (firstform.outmonth.value !="12" && firstform.retmonth.value !="01") {[/tt]

try passing in
12, 01 //false
x, 01 //false
12, x //false
x, x //true

So it is only true if the first one isn't 12 AND the second isn't 01. Is that what you are after?

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top