|
|
 |
FN-FORUM: Javascript checkbox fun.
date posted 26th August 2004 17:42
I've got a form where I'm making the checkboxes adopt
radio button (ish) behaviour. (Using radio buttons is=20
not an option, for reasons I shan't waste your time with).
So I am using (hoick, spit) Javascript.
My input looks a bit like this:
and the function currently looks like this:
// optionClicked takes name of Checkbox (group) and the=20
// option number (i.e. index +1)
function optionClicked(box,option) {
if (box.checked) {
index =3D option - 1;
boxarray=3D box.form.elements[box.name];
for (i=3D0; i < boxarray.length; i++) {
if (i !=3D index) boxarray[i].checked =3D false;
}
}
}
The option number is index +1 so as not to confuse any designers
that might need to maintain the code .
Comments please on (a) browser compatibility and (b) is there a=20
way of extracting the option number from the box rather than passing
it through?
|
 |
|