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):
Expand|Select|Wrap|Line Numbers
- <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="MoneyLaundering" method="post" action="listening_exam.asp">
An this is an example line for the option buttons:
<input type="radio" id="Q1" value="5" onClick="CalculateTotals()"/>
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