Select All/None checkboxes
This's just a small tip I want to take note.
- Here is the script:
- HTML file:
Enjoy this!
Trinh.
- Here is the script:
<script>
function checkboxEvent(){
var select_ckb = document.getElementById("select-all");
var select_list = document.getElementsByClassName("select");
if(select_ckb.checked) {
for(var i=0; i<select_list.length; i++) {
select_list[i].checked=true;
};
} else {
for(var i=0; i<select_list.length; i++) {
select_list[i].checked=false;
};
};
};
</script>
....
<input type="checkbox" id="select-all" onchange="checkboxEvent();">
<input type="checkbox" class="select">
<input type="checkbox" class="select">
....
Enjoy this!
Trinh.
Comments
Post a Comment