Javascript function not working with an array
- by Ryan Harvie
Hi,
i have this function which loops through an array of check boxes checking if the boxes value is equal to something in a text box, i dont know whats wrong.
function checkValue(contain) {
var boxes = document.getElementsByTagName("input");
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].name == "vote[]") {
if (boxes[i].value.indexOf(contain.value) != -1) {
boxes[i].checked = true;
}
}
}
}
and this is how i call it
OnClick="uncheckAll(); checkValue(document.getElementsByName("countrylist"));"
this code is in side a echo in php which is like this echo ' ';