Hi everyone. i'll also be posting this in the javascript forum.
I have a bunch of check boxes in my html. the name list[] was given so that the PHP script it would be directed to could grad the values out of the checkbox using an array.
<form name=myform>
<input type=checkbox name=list[] value="1">1<br>
<input type=checkbox name=list[] value="2">2<br>
<input type=checkbox name=list[] value="3">3<br>
<input type=checkbox name=list[] value="4">4<br>
<input type=checkbox name=list[] value="5">5<br>
</form>
as you can see the name is list[]
But how can i reference the list[] checkbox using javascript? if anyone has experience doing this.
here is my code so far which i've experiented with.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var field=document.myform.elements[0];
alert(document.myform.elements["list[]"][0].name);
// tried document.myform.list[][0].name
// tried document.myform.'list[]'[0].name
// tried document.myform.elements[0][0].name
// End -->
</script>
any help would be appreciated thanks.
I have a bunch of check boxes in my html. the name list[] was given so that the PHP script it would be directed to could grad the values out of the checkbox using an array.
<form name=myform>
<input type=checkbox name=list[] value="1">1<br>
<input type=checkbox name=list[] value="2">2<br>
<input type=checkbox name=list[] value="3">3<br>
<input type=checkbox name=list[] value="4">4<br>
<input type=checkbox name=list[] value="5">5<br>
</form>
as you can see the name is list[]
But how can i reference the list[] checkbox using javascript? if anyone has experience doing this.
here is my code so far which i've experiented with.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var field=document.myform.elements[0];
alert(document.myform.elements["list[]"][0].name);
// tried document.myform.list[][0].name
// tried document.myform.'list[]'[0].name
// tried document.myform.elements[0][0].name
// End -->
</script>
any help would be appreciated thanks.