I want the javascript to check only elements from one table if checked the corresponding table's checkbox only. JavaScript i have selects all rows from all the tables generated from a cgi script.
You can see multiple tables with information listed. If you select the checkbox of any below geneID, it checks all even from the other tables contents too. one possible problem i figured out is i have assigned same table id for all the tables, but as this is auto generated from a previous cgi script, i certainly cant find any possible solution to overcome it. Thank you any suggestions or comments are highly accepted.
<script type="text/javascript" language="javascript">
function SetAllCheckBoxes(ele) {
var checkboxes = document.getElementsByTagName('input');
if (ele.checked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
}
</script>
var checkboxes = document.getElementsByTagName('input');into selecting the correct table first, then find all the input elements inside that table only. Atm you select all the inputs on the screen, hence you check them all.