I have a group of radio buttons. If none of the radio button was checked, pop up an alert window. Otherwise submit the form. But the form cannot be submitted. I checked for a long time and still don't know why it doesn't work. I copied the code as follows. Thank you for your help.
Helen
- Code: Select all
<script language="javascript">
<!--
function checkStatus(buttonGroup) {
var j = checkRadioButton(buttonGroup);
if ( j == 1){
document.showStudentData.submit();
//[color=red]doesn't work[/color]
}
else {
alert("Please choose a student to edit");
//[color=red]works well [/color]
}
}
function checkRadioButton (radioGroup){
if (radioGroup[0]) { // if the button group is an array
for (var i=0; i<radioGroup.length; i++) {
if (radioGroup[i].checked) {
return 1
}
}
}
else {
if (radio.checked) { return 1; } // if one button is checked, return 1
}
// no radio button is selected
return -1;
} // Ends the "checkRadioButton" function
-->
</script>
...
<form name = "showStudentData">
...
echo "<center><input type=\"button\" name=\"submit\" value=\"Edit\" onClick='checkStatus(radio)'></center>";//[color=red]php [/color]code
...
</form>


