Hi forum,
This will probably be an easy one but i have a situation where i have multiple PHP/HTML <SELECT> tags. So i hold their id and name in an array. When i go to call this enableBox JavaScript function and i try to call the selectorName[] using the getElementById command, i get a null reference. How can i make this work, using the getElementById command in JavaScript to access the selectorName[] in PHP/HTML so that i can enable and disable a box depending on whether other has been selected in the dropdown selector?
PHP
for($i=0; $i<some number; $i++) {
<SELECT name="selectorName[]" id="selectorName[]" onChange="enableBox($i)">
<option> some value </option>
.....
</SELECT>
Please Specify Other: <input type=text name="other_name[]" id="other_name[]">
}
JavaScript
function enableBox(i) {
var selector = document.getElementById(selectorName[i]);
var otherBox = document.getElementById(other_name[i]);
alert(selector.value);
}