Use the name attribute to send back the question id to the server, and the value attribute to get the answer.
-- Consider this HTML FORM snippet:
<form>
<h3>Quiz on Electric Circuits</h3>
<hr>
<big><b>Question 1:</b></big> You know current and voltage but need to calculate resistance Which formula should you use?
<br><input type="radio" name="Q1" value="1">E = I * R</input>
<br><input type="radio" name="Q1" value="2">R = E / I</input>
<br><input type="radio" name="Q1" value="3">I = E / R</input>
<br><input type="radio" name="Q1" value="4">R = E * I</input>
<hr>
<big><b>Question 2:</b></big> Which of the following are true statements?
<br><input type="checkbox" name="Q2" value="1">Current is directly proportional to voltage.</input>
<br><input type="checkbox" name="Q2" value="2">Voltage is inversely proportional to current</input>
<br><input type="checkbox" name="Q2" value="3">Power is inversely proportional to current.</input>
<br><input type="checkbox" name="Q2" value="4">Power is directly proportional to current.</input>
<hr>
<big><b>Question 3:</b></big> You have two resistors. How do you wire them in series?
<br><input type="text" name="Q3"></input>
<hr>
<br><input type="submit" value="Submit"></input>
</form>
After the user selects their answers and clicks on the Submit button, your server should get a URL that looks like this:
Quiz.html?Q1=2&Q2=1&Q2=4&Q3=connect+them+end+to+end.
Notice how Q2 has two answer values.
Good luck.
On Wednesday, August 21, 2013 4:29:18 PM UTC-4, Sarfraz Ahmad wrote:
On Wednesday, August 21, 2013 4:29:18 PM UTC-4, Sarfraz Ahmad wrote:
Hello guys...I am working on a Quiz app where i have a bunch questions and a bunch of options for each question. for user input i have a bunch of of radio buttons, check boxes and text input fields related to each question. means a question can have 4 radio buttons for single choice question, 4 check boxes for multiple choice questions and text fields if user has to write the answer.Each of these check box, radio button or input element has two attributes question_id and answer_id. My problem is that i when a user click on the submit button i want to get the attribute of the fields the user selected so that i get to know the question id and answer id of the answer the user selected. Guys help me and tell me how can i do it using jQuery or javaScript
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.