i’ve been trying to debug this for almost 2 hours now, but no luck. i thought the problem was due to me not closing certain tags (such as the textarea tag), but its still going wrong when executed. i know that the solution must be ultra simple, but i keep missing something. any advice? thanks! here’s the code:
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“
<html>
<head>
<title>XMML.com – Online Survey</title>
<script type=”text/javascript” language=”javascript”>
<!–//
function IsFormValid(){
var IsFormValid = false;
if (document.MyForm.YourName.value!==”” && evalRadio()
&& document.MyForm.Comments.value!==””)
{
IsFormValid = true;
}
if (IsFormValid==false) DisplayErrors();
return IsFormvalid;
} // end IsFormValid() function
function evalRadio()
{
var group = document.MyForm.Gender;
for (var i=0; i<group.length; i++) {
if (group[i].checked) break;
}
if (i==group.length) return false;
else {return true;
} // end else
} // end evalRadio() function
function DisplayErrors (){
if (document.MyForm.YourName.value==””) alert(“Please enter your name”);
if (evalRadio()==false)
alert(“Please check the radio buttonnfor your gender”);
if (document.MyForm.Comments.value==””)
alert(“Please be sure to tell us the delivery address nfor your free gift”);
} // end DisplayErrors() function;
//–>
</script>
</head>
<body>
<form action=”
method=”POST” name=”MyForm” onsubmit=”return IsFormValid()”>
<table width=”600″>
<tr><th colspan=”3″ align=”center”>XMML.com – Online Survey<br /><br /></th>
</tr>
<tr>
<td>Your Name:</td>
<td> </td>
<td><input type=”text” name=”YourName”/></td></tr>
<tr>
<td>Your Gender:</td>
<td> </td>
<td>
<input type=”radio” name=”Gender” value=”Male”/>Male<br />
<input type=”radio” name=”Gender” value=”Female/>Female<br />
</td>
</tr>
<tr><td>Which of our consultancy <br />services are you interested in?</td>
<td align=”right”>
</td>
<td>
<input type=”checkbox” name=”XML”/> XML<br />
<input type=”checkbox” name=”XSLT”/> XSLT<br />
<input type=”checkbox” name=”SVG”/> SVG<br />
<input type=”checkbox” name=”XSL-FO”/> XSL-FO<br />
<input type=”checkbox” name=”XForms”/> XForms<br />
</td>
</tr>
<tr>
<td>Which free gift would your prefer for filling out this survey?</td>
<td> </td>
<td>
<select name=”FreeGift”>
<option value=”Choice1″>Fresh Air</option>
<option value=”Choice2″>A long life</option>
<option value=”Choice3″>Contentment</option>
</select>
</tr>
<tr>
<td>Enter your comments in<br />the text box
</td>
<td> </td>
<td><textarea name=”Comments” rows=”5″ cols=”50″/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><br /><input type=”submit” value=”Send Form”/></td>
</tr>
</table>
</form>
</body>
</html>
just to give you an idea, when executed this code creates a form with checkboxes, radio buttons and a user comment field with a send button.