I am creating a form for a registration that asks the participant if they have completed pre-requisite training. There are three questions they are asked. When they click yes, the text box for the requested information is enabled, when they click no, they get a warning that they need to register first.
Here is the javascript
<SCRIPT LANGUAGE="JavaScript">
function GetSelectedItem() {
chosen = ""
len = document.register.sere.length
for (i = 0; i <len; i++) {
if (document.register.sere[i].checked) {
chosen = document.register.sere[i].value
}
}
if (chosen == "yes") {
document.register.seredate.disabled=false
document.register.serecertificate.disabled=false
}
else {
alert("YOU MUST COMPLETE THE TRAINING BEFORE REGISTERING")
document.register.seredate.disabled=true
document.register.serecertificate.disabled=true
document.register.
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
function attrain() {
selected = ""
leng = document.register.attrain.length
for (i = 0; i <leng; i++) {
if (document.register.attrain[i].checked) {
selected = document.register.attrain[i].value
}
}
if (selected == "yes") {
document.register.atdate.disabled=false
document.register.atcertificate.disabled=false
}
else {
alert("YOU MUST COMPLETE THE TRAINING BEFORE REGISTERING")
document.register.atdate.disabled=true
document.register.atcertificate.disabled=true
}
}
</script>
and here is the html for the radio buttons
<div>
<label>Have you completed the SERE 100 Training?</label><br />
<input type="radio" name="sere" value="yes" onClick=GetSelectedItem() />Yes
<br />
<label>Enter date of SERE training. Must have been withing the last 365 days.</label>
<input name="seredate" id="seredate" disabled/>
<br />
<label>Enter SERE certificate number.</label>
<input name="serecertificate" id="serecertificate" disabled/>
<br />
<input type="radio" name="sere" value="no" onClick=GetSelectedItem() />No
<br />
<br />
<br />
</div>
<div>
<label>Have you completed the Anti-Terrorism Training?</label><br />
<input type="radio" name="attrain" value="yes" onClick=attrain() />Yes
<br />
<label>Enter date of Anti-Terrorism Training. Must have been withing the last 365 days.</label>
<input name="atdate" id="atdate" disabled/>
<br />
<label>Enter Anti-Terrorism certificate number.</label>
<input name="atcertificate" id="atcertificate" disabled/>
<br />
<input type="radio" name="attrain" value="no" onClick=attrain() />No
<br />
</div>
The first one works fine (the SERE training question), however, the second one does not function at all. What am I missing to enable the second question to function like the first.
Any help is greatly appreciated.
Thanks,