Hi,
if you name the input fields the same, they automatically become an array
<html>
<head>
<script>
<!--
function doit(oForm)
{
for (i = 0; i < oForm.length; i++)
if (oForm.elements[i].name == 'ipAdd')
alert(oForm.elements[i].va
}
//-->
</script>
</head>
<body>
<form name="a">
<input type="text" name="ipAdd" value="1">
<input type="text" name="ipAdd" value="2">
<input type="text" name="ipAdd" value="3">
<input type="text" name="ipAdd" value="4">
<input type='button' value='click 2C vals' onclick='doit(this.form)'
</form>
</body>
</html>
Vinny
Main Topics
Browse All Topics





by: NushiPosted on 2003-09-29 at 08:45:58ID: 9452364
hi there.
you simply use the array syntax:
var myArray = new Array();
now u can add variables to the arry based on index or Name:
myArray[0]='a';
myArray["3"] = 'b';
alert(myArray[0]) == a
alert(myArray("3")) == b;
Nushi.\