Javascript function not working with an array
Posted
by
Ryan Harvie
on Stack Overflow
See other posts from Stack Overflow
or by Ryan Harvie
Published on 2011-01-07T20:51:16Z
Indexed on
2011/01/07
20:53 UTC
Read the original article
Hit count: 126
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 ' ';
© Stack Overflow or respective owner