Java script code problem
i cant get the following code to work it is a function with a loop which is ment to display the name and values of the form when a button is clicked:
this is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<script language="text/javascript">
function display() {
for(i=0; i<document.form.elements.length; i++)
{
document.write ("the name is: " + document.form.elements[i].name +
"and the value is:" +
document.form.elements[i].value + "<br/>");
}
}
</script>
<form name= "form">
PLease Enter Your name:<br>
<input type="text" name="elementOne"><p>
What age group are you in?<br>
17-25 Yr<input type="radio" name="age1" value="17-25"><br>
25-35 Yr<input type="radio" name="age2" value="25=35"><p>
What sport do you like best?:<br>
<select name="sport" size="3">
<option>Surfing
<option>Football
<option>Basketball
</select><p>
What is your email address?
<input type="text" name="address">
</form>
<input type="button" value="test" onClick="display()">
</BODY>
</HTML>
|