|
-
Apr 12th, 2004, 07:48 PM
#1
Thread Starter
New Member
Javascript: Javascript problems
I'm having a very big problem with a very small JavaScript
Everytime I load the following page in IE6, it brings up the error:
A runtime error has occured
Do you wish to debug?
Line: 7
Error: 'return' statement outside of function
Code:
<html>
<head>
<title>Contact Us - CodingMasters</title>
<script language="javascript">
<!--function checkform(){
{if (document.formmail.body.value ="") or (document.formmail.changes.value ="")
alert("You did not fill in the comments box!")
return false}
else return true;
}
//-->
</script>
</head>
<body>
<P align="center"><FONT size="7" color="brown">CodingMasters</FONT></P>
<P align="center">"We give you what <EM>you</EM> want!"</P>
<BR>
<BR>
<center>
Here you can contact us using this form<BR>
<BR>
If <FONT color="#ff0000">*</FONT> is next to a field, it is compulsary<BR>
<form name="formmail" action="/cgi-bin/formmail/formmail.cgi" method="post" onsubmit="return checkForm()">
<input type="hidden" name="recipient" value="[email protected]" style="WIDTH: 185px; HEIGHT: 22px" size="23">
<p><b>Your Name:</b> <input name="realname" size="45"></p>
<br>
<p><b>Your Email Address:</b> <input name="email" size="45"></p>
<br>
<p><b>Comments or Suggestions:</b><br>
<TEXTAREA name="body" rows="8" wrap="virtual" cols="60"></TEXTAREA><FONT color="#ff0000">*</FONT></p>
<br>
<p><b>What would you change about the site:</b><br>
<TEXTAREA name="changes" rows="8" wrap="virtual" cols="60"></TEXTAREA><FONT color="#ff0000">*</FONT></p>
<br>
<p><b>Would you reccomend this site to your friends:</b><br>
<input type="radio" name="friends" value="Yes" checked><input type="radio" name="friends" value="No">
<FONT color="#ff0000">*</FONT>
<p><input type="submit" value="Send Email"> <input type="reset" value="Reset Form"></p>
</form>
<br>
<br>
E-Mail us @ <A HREF="mailto:[email protected]">[email protected]</A><BR>
<BR>
<A HREF="maillist.htm">Back</A>:<A HREF="index.html">Home</A><br>
This site is hosted by <A HREF="http://www.aurorahost.net">AuroraHost</A>
</center>
</body>
</html>
Thanks for any help anyone can give!
Matthew G.
-
Apr 12th, 2004, 09:43 PM
#2
Woah, your syntax is completely wrong in that function..
Code:
<script language="javascript">
<!--function checkform() {
if (document.formmail.body.value ="") or (document.formmail.changes.value ="")
{
alert("You did not fill in the comments box!") ;
return false;
}
else
{
return true;
}
}
//-->
</script>
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 13th, 2004, 05:42 AM
#3
To add, put the function keyword on its own line, not directly after the html comment. And the comparison operator is ==, not =.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 13th, 2004, 10:27 AM
#4
Frenzied Member
and it's
if ((document.formmail.body.value =="") || (document.formmail.changes.value =="") )
not
if (document.formmail.body.value ="") or (document.formmail.changes.value ="")
|| is or, && is and
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|