JavaScript problems

codingmasters
I'm having problems with the most simplest of Scripts you could write in 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



<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="codingmasters@yahoo.com.au" 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:codingmastershelp@yahoo.com.au">codingmastershelp@yahoo.com.au</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

Matthew G.

codingmasters
Alright, I've been to vbforums.com, and after much tinkering with the file, i've come up with this:

<html>
<head>
<title>Contact Us - CodingMasters</title>
<script language="javascript">
<!--function
formcheck;
if (document.formmail.body.value =="") || (document.formmail.changes.value =="");
{alert("You did not fill in the comments or changes 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 "formcheck">
<input type="hidden" name="recipient" value="codingmasters@yahoo.com.au" 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:codingmastershelp@yahoo.com.au">codingmastershelp@yahoo.com.au</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>


I'm still getting this error, over and over:
[quote]Line: 6
Error: Syntax Error

Anonymous
Been away a while, but seeing as though no-one else has stepped in, better late than never :shock:

Try this (slightly re-worked) code...


<html>
<head>
<title>Contact Us - CodingMasters</title>
<!-- Hide the script from non javascript browsers
<script language="javascript">
//function
formcheck;
if (document.formmail.body.value =="") || (document.formmail.changes.value =="");
{alert("You did not fill in the comments or changes box!");
return false};
else;
{return true};
//-End of function
</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 "formcheck">
<input type="hidden" name="recipient" value="codingmasters@yahoo.com.au" 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:codingmastershelp@yahoo.com.au">codingmastershelp@yahoo.com.au</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>




There seemed to be a bit of confusion in the way you used the javascript & html 'comment markers' in the original efforts

Al (MaDbRiT)

GameBoy
forms are best in PHP i thinks :D

paul_one
That they are Ste - that they are..... Alot easier to use something that's almost function-like.

007bond
I'm using VB6 and I'm doing a project on Space. I need to know how to create and delete an Image control.
Any help would be appreciated.

007bond

Anonymous
007 Bond wrote;

I'm using VB6 and I'm doing a project on Space. I need to know how to create and delete an Image control



The image control doesn't appear on your default set of controls in VB6, it has to be added by adding the "Microsoft Common Controls 6" (if I remember correctly, don't have VB6 on this PC)

In the VB workspace, select the PROJECT menu, then COMPONENTS in the tabbed dialog that pops up (it should default to the CONTROLS tab) you have a scrollable list of controls you can add to your toolbox (n.b. for this project only!)

Scroll down the list until you find MICROSOFT COMMON CONTROLS 6.0 - tick the appropraite box and then click APPLY.

You will now have a few extra controls to play with in your toy box... oops TOOL box... :-)

I THINK MCC6.0 adds a tabbed dialog control, toolbar control, status bar control, progress bar control, treeview control, listview control, imagelist control, slider control & an image combo control.

Using any of these is easy as drag and dropping/ double clicking - just like any other VB control.

Al (MaDbRiT)

Anonymous
Oh yeah - I was assuming above that you didn't mean the standard 'image' control on the default toolbar! I'm sure you don't need help finding/using that...

do you?

Al (MaDbRiT)

007bond
Sorry, I meant at runtime, not at design time.
And for the record an Image Control is part of the intrisc collection of controls in VB6

007bond

paul_one
can;t you just change the visibility to true and to false??

007bond
No, because the user doesn't necessarily have to click on the button.

I guess I should give a bit more background info:
It's a school project.
It's basically a seven form app: The main form, The about form, the planets form, the stars form, the Sun form, the martians form and the game form.
The 3rd to the 6th form each have buttons on them which changes the text in the texbox and shows an image. However, one button requires a second image to be shown. So, I need the image to be created at runtime.

Hope that helps.

007bond

007bond
don't worry, I've found a way to view the second picture without having to create another image control at runtime

007bond

This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums