Moderator |
|
Hiermee zou je kunnen controleren of een radio-button gechecked is:
// function to check whether a radio-button is selected
function check_if_checked(frm, elt) {
var ret = false; // whether a radio-button is checked
var i=0;
if(typeof(frm) == "object") {
// frm was passed by reference
while(!ret && i < frm.elements[elt].length) {
ret = frm.elements[elt][i].checked;
i++;
}
} else {
// assume frm is a string
while(!ret && i < document.forms[frm].elements[elt].length) {
ret = document.forms[frm].elements[elt][i].checked;
i++;
}
}
return ret;
}
// function to check whether a radio-button is selected function check_if_checked(frm, elt) { var ret = false; // whether a radio-button is checked var i=0; if(typeof(frm) == "object") { // frm was passed by reference while(!ret && i < frm.elements[elt].length) { ret = frm.elements[elt][i].checked; i++; } } else { // assume frm is a string while(!ret && i < document.forms[frm].elements[elt].length) { ret = document.forms[frm].elements[elt][i].checked; i++; } } return ret; }
In jouw geval dus aanroepen met check_if_checked("form", "type"); als je form "form" heet, en je radio-button "type".
"type" is overigens niet een heel erg handige naam... |