I have 3 radio buttons and need to choose one (BAT) when the page loads. Here is the HTML in question.
<td valign="center">
<input id="T1" name="ZZ" type="radio" value="CAT"/> <label for="T1"> cat </label><br/>
<input id="T2" name="ZZ" type="radio" value="DOG"/> <label for="T2"> dog </label><br/>
<input id="T3" name="ZZ" type="radio" value="BAT"/> <label for="T3"> bat </label><br/>
</td>
Here is the code that I'm using.
var elements = document.getElementsByTagName("input");
for (i = 0; i < elements.length; i++) {
if (elements[i].value == "BAT") {
elements[i].click();
}
}
Can anybody spot what I'm doing wrong? The radio button is never selected unfortunately.