Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
179
rated 0 times [  181] [ 2]  / answers: 1 / hits: 16287  / 9 Years ago, fri, june 12, 2015, 12:00:00

When i click One Main Select radio button,it should select all the radio buttons in my Form.The same Way When I deselect The any one of the radio Button,it should deselect the main Radio Button(which is used to select all the radio button).


More From » javascript

 Answers
10

Finally, I've found the solution for the above issue. It looks like this:



function onClickHeader(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++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
}

[#66230] Wednesday, June 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaia

Total Points: 574
Total Questions: 109
Total Answers: 110

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;