View Single Post
  #1 (permalink)  
Old 04-12-2006, 09:09 PM
sarah sarah is offline
Junior Member
 
Join Date: Apr 2006
Posts: 2
Default Java script code problem

i cant the the following code to work it is ment to be a function with a loop which displays the name and values of the form when a button is click;
please help

<!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>
Reply With Quote