/    Sign up×
Community /Pin to ProfileBookmark

Another form problem driving me bananas

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”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<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=”http://www.XMML.com
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>&nbsp;</td>
<td><input type=”text” name=”YourName”/></td></tr>
<tr>
<td>Your Gender:</td>
<td>&nbsp;</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”>&nbsp;
</td>
<td>
<input type=”checkbox” name=”XML”/>&nbsp;XML<br />
<input type=”checkbox” name=”XSLT”/>&nbsp;XSLT<br />
<input type=”checkbox” name=”SVG”/>&nbsp;SVG<br />
<input type=”checkbox” name=”XSL-FO”/>&nbsp;XSL-FO<br />
<input type=”checkbox” name=”XForms”/>&nbsp;XForms<br />
</td>
</tr>
<tr>
<td>Which free gift would your prefer for filling out this survey?</td>
<td>&nbsp;</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>&nbsp;</td>
<td><textarea name=”Comments” rows=”5″ cols=”50″/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</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.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@scojo1Jan 06.2006 — This:
[CODE]<textarea name="Comments" rows="5" cols="50"/>[/CODE]

Should be this:

[CODE]<textarea name="Comments" rows="5" cols="50"></textarea>[/CODE]

also:
[CODE]<input type="radio" name="Gender" value="Female/>[/CODE]

should be:
[CODE]<input type="radio" name="Gender" value="Female" />[/CODE]

Hope that solves your problem
Copy linkTweet thisAlerts:
@fuzion79authorJan 06.2006 — it worked! thanks!
Copy linkTweet thisAlerts:
@scojo1Jan 06.2006 — no problem
×

Success!

Help @fuzion79 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...