Hi
I have a page that contains a number of sets of four radio buttons, written as a loop in php. At the top, I want to have four buttons you can click on to get all the sets checked. As in click the first button, and the first radio button in all the sets gets selected. I did the same for a row of checkboxes, but I'm unable to get the code for the radio buttons to work. What am I doing wrong? Note that this code isn't all mine, I've scrounged the net and put together code from examples. Test is the name of the form, and the *_buttons are the names of the buttons.
window.onload=function()
{
document.getElementById("o
k_button")
.onclick = checkallradio;
document.getElementById("m
indre_butt
on").oncli
ck = checkallradio;
document.getElementById("s
tore_butto
n").onclic
k = checkallradio;
document.getElementById("n
otdone_but
ton").oncl
ick = checkallradio;
};
function checkallradio() {
for (var j=0;j < document.test.length;j++)
{
if (document.test.elements[j]
.type == 'radio') {
{
objEl = document.test.elements[j];
//Test which 'checkall' button was clicked. 'this'
//refers to the button that was clicked:
switch (this.id)
{
case "ok_button":
//then check first radio button
//in the group:
objEl[0].checked=true;
break;
case "mindre_button":
//then check second radio button
//in the group:
objEl[1].checked=true;
break;
case "store_button":
//then check third radio button
//in the group:
objEl[2].checked=true;
break;
case "notdone_button":
//then check fourth radio button
//in the group:
objEl[3].checked=true;
break;
}
}
}
Start Free Trial