I am an extreme beginner in terms of checking Java script, so I won’t be surprised if literally everything in my code is wrong.
I am trying to check my switches.
I previously used this format to try to do this:
if (document.ExamEntry.GCSE.checked == true) {
confirm("You have selected GCSE. Is this correct?");
if (document.ExamEntry.A2.checked == true) {
confirm("You have selected GCSE. Is this correct?");
if (document.ExamEntry.A2.checked == true) {
confirm("You have selected A2. Is this correct?");
because I want it to give a message for each switch, but of course it didn't work. (The sumbit button worked as a redirect to the next page, but the cancel button did the same thing as it didn’t receive a command that I didn’t know how to do) I was told that the onClick command would be good, but I tried it still failed, because I was not sure how to apply it.
So, I tried to do this: (my new code)
functioncheckRadio () {
var level = "";
var qualification = document.ExamEntry.Rbutton.value;
var i;
for (i=0; i <qualification; i++) {
if (document.ExamEntry.qualification[i].checked) {
level = document.ExamEntry.Rbutton.value;
break;
}
}
if (level == "") {
document.getElementById("Rbutton").innerHTML = "You must
select a qualification level";
return false;
}
else {
document.getElementById("Rbutton").innerHTML = "";
return = true;
}
}
and this is my html:
<td id="RadioGCSE">GCSE</td>
<td><input type="radio" name="Rbutton" value="GCSE" id="r1" checked = "checked" /></td>
<tr>
<td id="RadioAS">AS</td>
<td><input type="radio" name="Rbutton" value="AS" id="r2" /></td>
</tr>
<td id="RadioA2">A2</td>
<td><input type="radio" name="Rbutton" value="A2" id="r3" /></td>
<tr>
, . :
GCSE, : " GCSE. " , , , , .
/ . - .