I am creating a quiz that has 20 questions. For each question I have 5 option buttons. A user chooses an option for each question and the option will be weighted from 5 to 1. The webpage is has an .asp extension (not sure if this is what is causing me a problem).
I have put an input box at the bottom of the page and I would like the total to be calculated everytime and option is clicked on.
the function I am using is this (I have put this at the top of the page):
This is the first line of the form tag:
<form id="MoneyLaunde ring" method="post" action="listeni ng_exam.asp">
An this is an example line for the option buttons:
<input type="radio" id="Q1" value="5" onClick="Calcul ateTotals()"/>
For each of the questions I have changed the id (so all question 1 option buttons are named "Q1", buttons in question 2 are named "Q2" etc).
At the moment, I cannot even select a button on the web page (only Q1 option buttons have the onClick bit in as I'm just testing at the moment, so I don't see any reason why the other buttons should not be).
i have only put two of the buttons into the function for testing purposes. i would be grateful if anyone can help me with my problem ( I am totally new to javascript but know a bit of VBA and ASP!!)
thanks in advance
Tom
I have put an input box at the bottom of the page and I would like the total to be calculated everytime and option is clicked on.
the function I am using is this (I have put this at the top of the page):
Code:
<script language="javascript">
<!--
function CalculateTotals(){
f=document.MoneyLaundering
if (f.Q1=true)
{
var total1=5
}
else if (f.Q2=true)
{
var total1=4
}
f.grandtotal.value =parseInt(total1)
+parseInt(total2);}
//-->
</Scipt>
<form id="MoneyLaunde ring" method="post" action="listeni ng_exam.asp">
An this is an example line for the option buttons:
<input type="radio" id="Q1" value="5" onClick="Calcul ateTotals()"/>
For each of the questions I have changed the id (so all question 1 option buttons are named "Q1", buttons in question 2 are named "Q2" etc).
At the moment, I cannot even select a button on the web page (only Q1 option buttons have the onClick bit in as I'm just testing at the moment, so I don't see any reason why the other buttons should not be).
i have only put two of the buttons into the function for testing purposes. i would be grateful if anyone can help me with my problem ( I am totally new to javascript but know a bit of VBA and ASP!!)
thanks in advance
Tom
Comment