help on Javascript form calculating

kylexy's Avatar, Join Date: Feb 2012
Go4Expert Member
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
mialuzzatto's Avatar, Join Date: Aug 2015
Go4Expert Member

We will learn how to perform calculations using JavaScript. It is quite often required to do calculations online in order forms, request quote forms and the like. This tutorial will show you how to use different form elements like drop-down list, radio button, check box and text box in a calculation.

We will be using a ‘cake order form’ as an example. As the user makes selections in the form, the total price is calculated in real time.

Mia Luzzatto