473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Javascript Quiz

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):

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. <!--
  3. function CalculateTotals(){
  4.     f=document.MoneyLaundering
  5.  
  6.     if (f.Q1=true)  
  7.     {
  8.     var total1=5
  9.     }
  10.     else if (f.Q2=true) 
  11.     {
  12.     var total1=4
  13.     }
  14.  
  15.     f.grandtotal.value =parseInt(total1)
  16.                 +parseInt(total2);}
  17.  
  18.  
  19.  
  20. //-->
  21. </Scipt>
This is the first line of the form tag:

<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
May 24 '07 #1
3 1223
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

To access Q1, use
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("Q1");
Then loop through and check which one is checked.
May 24 '07 #2
Welcome to TSDN!

To access Q1, use
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("Q1");
Then loop through and check which one is checked.

Thanks for the reply. mabe I should have said i'm REALLY new to javascript!!! Does anyone know of any tutorials that have something similar that I could use?? The syntax of javascript is a bit alien to me and unfortuantely I don't have much time to devote to this!!

Thanks again for the reply though.

Tom
May 24 '07 #3
acoder
16,027 Expert Mod 8TB
See if you understand this.
May 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: C. David Rossen | last post by:
Hello: I found a script for a simple multiple choice quiz that I would like to tailor to a quiz that I want to post on a website. The quiz I want to use can be found at : ...
2
by: Sketcher | last post by:
Hi, I am trying to create a quiz, Code is as follows: <html> <head> <title>Quiz</title> </head> <BODY> <Center><TABLE cellSpacing=3 cellPadding=0 border=0>
17
by: rgoya | last post by:
Peace be with you! About a year ago, I created a JavaScript which turns any web site into an online anti-war protest: http://www.geocities.com/rgoya/javascript/PROTEST.HTM I have recently...
6
by: Vandana Rola | last post by:
Hello Everyone, I posted this question earlier under creating Multiple choice quiz. Is it possible to ignore something using javascript. What I am trying to do is creating a multiple answer...
1
by: number1.email | last post by:
Hello, I have a simple Web Page Questionairre in which questions are read from a database, and the user can indicate the correct answer via either a radio input control or a dropdown list. The...
11
by: admin | last post by:
Hi all, First time poster here... I'm a webmaster and I'd like to add a simple script to my website which will allow users to fill in a brief multiple choice questionaire, and then provide a...
2
by: kenny | last post by:
I'm making a quiz to be posted on the internet. but I'm facing difficulties in finding a simple timer for the quiz (unlimited timing) which will keep on running regardless to the change of the page...
2
by: Surya Vellanki | last post by:
Hi all, I have been struggling with this problem from a few days. I hope I will get some help here. I am developing an online quiz portal with ASP.NET 2.0 and I am using Atlas framework for...
5
by: Steve | last post by:
I need to make an HTML page that has multiple choice quiz questions that pull from an XML doc. I have been looking at various online examples of how to do this, mainly this one:...
8
by: danjoplin | last post by:
I've only recently started javascript and I'm a java programmer so I'm sure I've done something obvious that I can't see. Basically this goes with an html document which has a number of questions on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.