Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP and JavaScript question

Status
Not open for further replies.

ksoong

Programmer
Oct 3, 2000
57
CA
Hi everyone. i'll also be posting this in the javascript forum.

I have a bunch of check boxes in my html.
<form name=myform>
<input type=checkbox name=list[] value=&quot;1&quot;>1<br>
<input type=checkbox name=list[] value=&quot;2&quot;>2<br>
<input type=checkbox name=list[] value=&quot;3&quot;>3<br>
<input type=checkbox name=list[] value=&quot;4&quot;>4<br>
<input type=checkbox name=list[] value=&quot;5&quot;>5<br>
</form>

as you can see the name is list[] so that when i bring it to a php script it can be referenced as an array.

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=&quot;JavaScript&quot;>
<!-- Begin

var field=document.myform.elements[0];
alert(document.myform.elements[&quot;list[]&quot;][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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top