Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   help on Javascript form calculating (http://www.go4expert.com/forums/help-javascript-form-calculating-t28149/)

kylexy 7Apr2012 22:30

help on Javascript form calculating
hi guys... i am in need 4 some help here. just started the javascript and don't know much about it. so .... i'm using HTML form tag to create a test, with 13 questions, each of them with two possibilities, right or wrong. So the user will check 1 radio button completing the 13 questions, the thing is... What javascript code can i use, to calculate the right and the wrong answers ?

this is the basic structure of the code, *Note: value 1 means right, and value 2 means wrong.
HTML Code:

<title>My Test</title>
<form name="mytest">
<table cellspacing="1" cellpadding="2" border="0">
<td>first question.... is it right or wrong ?<input type="radio" name="question1" value="1"> | <input type="radio" name="question1" value="2">
<td>this is question 2... is it right or wrong ?<input type="radio" name="question2" value="1"> | <input type="radio" name="question2" value="2">

... etc etc this is how the rest of the code goes, and in the end
HTML Code:

<tr><td><input type="button" value="Calculate Results" onClick="CalcRes()" /></td></tr>
So ... how can i get the value of the radio buttons and display results in a popup box using Javascript ? (not nesecarely in a popup box, a dic would be fine too )
Total right awnswers : (nr of right awnsers)
Wrong awnsers: (nr of wrong awnsers)
Wrong awnsers: (the names of buttons with vale 2, ex: question1, question4 ... )

I need this to run in Client mode only.please help, i'd be very graceful

All times are GMT +5.5. The time now is 22:01.