I create a varying amount of radiobutton-rows with PHP and give them names like 1, 2, 3, etc. So now I have stuff like this in my HTML file:
<input type="radio" name="0" value="on" checked="">
<input type="radio" name="0" value="off" >
<input type="radio" name="0" value="solo" >
<input type="radio" name="1" value="on" checked="">
<input type="radio" name="1" value="off" >
<input type="radio" name="1" value="solo" >
<input type="radio" name="2" value="on" checked="">
etc.
Now I want to check the states of all radiobuttons with Javascript (don't worry, I know the number of radio rows):
for(var i = 0; i < amountOfRadioRows; i++) {
for( var j = 0; j < 3; j++) {
if(document.formName.i[j].checked) {
alert(i+" "+j+" is checked!");
}
}
}
But here's my problem: How can I access the individual radiobuttons with a variable?
Additional information: Ultimately, my page should load some values from a CSV file (done), display 3 radiobuttons for each position (done) and calculate and display the average of these numbers, depending on which options the user chose. I'd be happy on any input on this :)