Click to See Complete Forum and Search --> : add values of form


alxtech
02-05-2008, 12:00 PM
i have this form that has questions with the answer on radio buttons selected by user:

<td>Question 1</td>
<td><input type="radio" name="questionone" value="100" id="questionone_0" /></td>
<td><input type="radio" name="questionone" value="80" id="questionone_1" /></td>
<td><input type="radio" name="questionone" value="60" id="questionone_2" /></td>

<td>Question 2</td>
<td><input type="radio" name="questiontwo" value="90" id="questionone_0" /></td>
<td><input type="radio" name="questiontwo" value="70" id="questionone_1" /></td>
<td><input type="radio" name="questiontwo" value="50" id="questionone_2" /></td>


I need that on form submit add the values to a variable of the item selected for each question.
do you have any suggestion how to achieve that.

toicontien
02-05-2008, 01:36 PM
First, do you know how to hook an onsubmit event handler to a FORM tag? Then, read up on the two blog posts below:

JavaScript, DOM, and the Humble FORM (http://fundamentaldisaster.blogspot.com/2007/10/javascript-dom-and-humble-form.html)

A Practical Guide To Numbers in JavaScript (http://fundamentaldisaster.blogspot.com/2007/11/practical-guide-to-numbers-in.html)

JMRKER
02-05-2008, 04:22 PM
For a goofy example that uses 'select lists' rather than 'radio buttons' you can look at
post #15 of http://www.webdeveloper.com/forum/showthread.php?t=172576

Some modifications will be needed to change select lists to radio buttons for checking the values,
but may help in understanding of JS coding.

Post back if you still have problems.