Page 1 of 1

Correcting Javascript If statements?

Posted: Sat Feb 17, 2007 9:19 pm
by phpsmart
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello everybody...
I dont know what is wrong in this if statement when i click on the button which is supposed to call this function this error message appears:
Parse error: parse error, unexpected '[syntax="javascript"]\forum_exec5.php on line 6.
Here is the code:

[syntax="javascript"]
function validate() {
//line 6// if ((document.forms[0].elements[0].value='') && 
(document.forms[0].elements[1].value=''))
{
alert('You must enter the topic title and details')
}


else
{

document.forms[0].submit();

}
}

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Feb 17, 2007 9:43 pm
by nickvd
You're missing the closing brace '}' for the validate function.

Posted: Sat Feb 17, 2007 9:54 pm
by phpsmart
Now i corrected it but it also gives me the same error message...
I'm sure it has to do something with the syntax of the if statement...

Posted: Sat Feb 17, 2007 9:57 pm
by nickvd
Unless I'm blind, the if statement is fine... You'll have to post more of your javascript code, as after fixing the closing brace, it should have fixed your errors...

Posted: Sat Feb 17, 2007 10:10 pm
by feyd
= vs == maybe?

Posted: Sat Feb 17, 2007 10:57 pm
by nickvd
Ooop, I guess I am blind... 8)