Forum Moderators: coopster

Message Too Old, No Replies

access each element of a control array

         

jasons

2:11 am on Feb 19, 2006 (gmt 0)

10+ Year Member



hi,
I have code as follows generated by php from reading records from a database:
<select name="menu[]" onchange="change(1)">
<option>...</option>
...
</select>
...
<select name="menu[]" onchange="change(2)">
<option>...</option>
...
</select>
and on and on...

it works fine, except that javascript::change(i) (i tells change() which "select" calls the function) does not know how to access the menu control because they have the same name. any ideas to solve the problem? really appreciate it.

jasons

2:58 am on Feb 19, 2006 (gmt 0)

10+ Year Member



this is what I tried, but it does not work,

function Change(i){
var a=document.f.elements["menu[]"];
if(a[i].value==-1) {
window.open(...);
}
}