PDA

View Full Version : Check all checkboxes


Shaolins-Finest
09-05-2008, 03:16 PM
Hi Guys

I have a form as follows:


<a href="#" onclick="somefunction()"/>check all</a>

<form name="test" action="#">
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
</form>
When I click on the "check all" button I want to select all of the checkboxes. How can I do this ?








.

rangana
09-06-2008, 12:26 AM
Hope this helps:

function somefunction(){
for(var i=0,check=document.getElementsByTagName('input');i<check.length;i++)
if(check[i].getAttribute('type')=='checkbox') check[i].checked=true;}