Link to home
Start Free TrialLog in
Avatar of DuffeyP
DuffeyP

asked on

Checkbox JavaScript

I have the following script where one checkbox selects a column of radio buttons (Radio0) and another de-selects it. I would like to combine these into a single checkbox where checking selects and unchecking de-selects it.

Here is the JS code I have now.

<script>

//Check all radio/check buttons script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use  

function checkall(formname,checkname,thestate){
var el_collection=eval("document.forms."+formname+"."+checkname)
for (c=0;c<el_collection.length;c++)
el_collection[c].checked=thestate
}

</script>

And here is the code for the 2 checkboxes that select the column of radios. I would like to combine these into a single checkbox that both selects and de-selects.

<input type="checkbox" name="All" value="0" onClick="javascript:checkall('theform','Radio0',true)">

<input type="checkbox" name="All" value="0" onClick="javascript:checkall('theform','Radio0',false)">
ASKER CERTIFIED SOLUTION
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DuffeyP
DuffeyP

ASKER

Thanks - that did the trick. Appreciate the quick response.
You're welcome and thanks for the points