1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help on Javascript form calculating

Discussion in 'JavaScript and AJAX' started by kylexy, Apr 7, 2012.

  1. kylexy

    kylexy New Member

    Feb 21, 2012
    Likes Received:
    Trophy Points:
    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.
    <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
    <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
  2. mialuzzatto

    mialuzzatto New Member

    Aug 5, 2015
    Likes Received:
    Trophy Points:
    Work at https://www.idevelopersquare.com
    Waltham, MA, USA
    Home Page:

    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

Share This Page