Select a certain amount of checkbox arrays on the page

Posted by Joris Tobebech on Stack Overflow See other posts from Stack Overflow or by Joris Tobebech
Published on 2011-01-09T17:44:09Z Indexed on 2011/01/09 17:53 UTC
Read the original article Hit count: 306

Filed under:
|
|
|
|

Hi guys,

so i wrote a function to select a certain amount of checkboxes on the page, the number retrieves fine when i message box it but no checkboxes are checked.

here is my function

function checkAmount(number)  
{  
alert(number);      
var boxes = document.getElementsByTagName("input");  
for (var i = 0; i < number; i++) {  
    if (boxes[i].name == "vote[]") {  
        boxes[i].checked = true;  
    }  
}  
}

and here is my execution code

 OnClick="checkAmount(document.getElementById(\'ammount\').value)"

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript