Javascript| selected
function Getcheckedvalue (radioobj) ... {
if (!radioobj)
Return "";
var radiolength = radioobj.length;
if (radiolength = = undefined)
if (radioobj.checked)
return radioobj.value;
Else
Return "";
for (var i = 0; i < radiolength; i++) ... {
if (radioobj[i].checked) ... {
return radioobj[i].value;
}
}
Return "";
}
function Check ()
... {
for (i = 0; i < document.submitform.all.length i++) ... {
if (Document.submitform.all (i). TagName = = "INPUT") ... {
var oitem = Document.submitform.all.item (i);
var sname = Oitem.name;
if (oitem.type.toLowerCase () = = "Radio") ... {
if (Getcheckedvalue (Document.getelementsbyname (oitem.name)) = = "") ... {
Oitem.focus ();
Window.scrollby (0,-30);
Alert ("Please fill in all the questions carefully.") ");
return (false);
}
}
}
}
Document.submitform.submit ();
}
Getcheckedvalue gets the values of the Radio box,
Return the value of the radio button this is checked
Return a empty string if none are checked, or
There are no radio buttons
function Getcheckedvalue (radioobj) {
if (!radioobj)
Return "";
var radiolength = radioobj.length;
if (radiolength = = undefined)
if (radioobj.checked)
return radioobj.value;
Else
Return "";
for (var i = 0; i < radiolength; i++) {
if (radioobj[i].checked) {
return radioobj[i].value;
}
}
Return "";
}
Set the radio button with the given value as being checked
Do no if there are no radio buttons
If the given value does not exist and all the radio buttons
are reset to unchecked
function Setcheckedvalue (radioobj, NewValue) {
if (!radioobj)
Return
var radiolength = radioobj.length;
if (radiolength = = undefined) {
radioobj.checked = (Radioobj.value = = newvalue.tostring ());
Return
}
for (var i = 0; i < radiolength; i++) {
radioobj[i].checked = false;
if (Radioobj[i].value = = newvalue.tostring ()) {
Radioobj[i].checked = true;
}
}
}
Check function to determine if all of the radio boxes are not selected, if any are displayed.