hey all,
I am working on a site for a teacher that has an online exam to it. What I am working on is basically 10 multiple choice questions, each with 4 possibilities. Imagine the html for this as follows (this is arbitrary off the top of my head so I hope that it is right... I don't work with forms often):
<form name="test">
<b> 1) What is 2 plus 2? </b> <br />
<input type="radio" name="q1" value=http://www.webdeveloper.com/forum/archive/index.php/"1"> one. <br />
<input type="radio" name="q1" value="2"> two. <br />
<input type="radio" name="q1" value="3"> three. <br />
<input type="radio" name="q1" value="4"> four. <br />
THE OTHER NINE QUESTIONS GO HERE!
</form>
ok, so, I know that radio buttons are referred to as an array, such as:
var answer = document.test.q1[1].value;
My question is this: Is there a way to just get the selected value of the array of buttons? By that what I mean is can I just refer to the radio button by name, and obtain the value of the button that is selected. i.e.
var answer = document.test.q1.value?
Now, I know that the above is incorrect, but I am hoping I can just do something like that instead of having to look at EACH button in the "q1" array to find the selected one and its value.
I really hope that makes sense as I am typing in a rush right now. I am asking this so I can write the function that totals the students score, and also tells them which one(s) that they got wrong.
Thanks in advance for any help!
I am working on a site for a teacher that has an online exam to it. What I am working on is basically 10 multiple choice questions, each with 4 possibilities. Imagine the html for this as follows (this is arbitrary off the top of my head so I hope that it is right... I don't work with forms often):
<form name="test">
<b> 1) What is 2 plus 2? </b> <br />
<input type="radio" name="q1" value=http://www.webdeveloper.com/forum/archive/index.php/"1"> one. <br />
<input type="radio" name="q1" value="2"> two. <br />
<input type="radio" name="q1" value="3"> three. <br />
<input type="radio" name="q1" value="4"> four. <br />
THE OTHER NINE QUESTIONS GO HERE!
</form>
ok, so, I know that radio buttons are referred to as an array, such as:
var answer = document.test.q1[1].value;
My question is this: Is there a way to just get the selected value of the array of buttons? By that what I mean is can I just refer to the radio button by name, and obtain the value of the button that is selected. i.e.
var answer = document.test.q1.value?
Now, I know that the above is incorrect, but I am hoping I can just do something like that instead of having to look at EACH button in the "q1" array to find the selected one and its value.
I really hope that makes sense as I am typing in a rush right now. I am asking this so I can write the function that totals the students score, and also tells them which one(s) that they got wrong.
Thanks in advance for any help!