Correcting Javascript If statements?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
phpsmart
Forum Newbie
Posts: 6
Joined: Wed Jan 31, 2007 5:20 pm

Correcting Javascript If statements?

Post 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]
Last edited by phpsmart on Sat Feb 17, 2007 9:52 pm, edited 1 time in total.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

You're missing the closing brace '}' for the validate function.
phpsmart
Forum Newbie
Posts: 6
Joined: Wed Jan 31, 2007 5:20 pm

Post 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...
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

= vs == maybe?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Ooop, I guess I am blind... 8)
Post Reply