I have an html table with a checkbox on each row. My javascrpt filters rows based on a text box above the table. I need a function that will only check the boxes on visible rows. I'm stumped.
chkbuild is the name of all the checkboxes in the table. ID is unique. chkallnone is my header checkbox to select all or none.
example of table row cell
<td><input type="checkbox" id="(counter)" name="chkbuild" value="(unique ids)"></td>
Javascript code for selecting checkboxes.
function checkCheckboxes( id, pID ){
var ele=document.getElementsByName('chkbuild');
var TrueFalse = true;
//determine if the select all checkbox is checked or unchecked.
if (document.getElementById('chkallnone').checked) {
TrueFalse = true;
} else {
TrueFalse = false;
}
//cycle through all table checkboxes and set their checked value
for(var i=0; i<ele.length; i++){
ele[i].checked=TrueFalse;
}
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/HOGBID2
Comments
Post a Comment