472,968 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

HELP! Simple Javascript Problem, Simpler Me!

not
Hello All,

I am trying to develop a relatively simple self-quiz form in
javascript, but I'm having no luck getting it to work.

What I am looking for is a script that allow the user to select one of
three answers for each question, and automatically assign a value to
their answer ("never"=0, "sometimes"=1, "always"=2). There would be
anywhere from ten to thirty questions. I want the script to calculate
the running total, and then display that total at the bottom of the
input section. FYI, there I would add text to the effect of "your
total score is [x]. A score of 0-10 means this, 11-20 means that, and
21-30 means somthing else."

Conceptually it seems so simple to me. But all the scripts I write
(or, actually, find-and-tweak) either over-calculate (in other words,
multiple clicks on a "yes" radio button increase the total) or only
calculate the last set of values (i.e. question 5 out of 5 but not
1-4). Any help would be most appreciated.

Munged code follows. I've stripped it down to its essentials (actually
well beyond that, hence the problem). There's a big hole where the
javascript itself should go. I feel certain there's a straightforward
solution to this. Yet it's seemingly beyond me....

Bill

-----------------------------

<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
// End -->
</script>
</head>

<body>

<form method="POST" name="myform">

<table border=1 cellpadding=2>

<tr>
<td align=center>Never</td>
<td align=center>Sometimes</td>
<td align=center>Always</td>
<td>&nbsp;</td>
</tr>

<tr>
<td align=center valign=top><input type="radio" name="1"
onclick="this.form.total.value=0;"></td>
<td align=center valign=top><input type="radio" name="1"
onclick="this.form.total.value=1;"></td>
<td align=center valign=top><input type="radio" name="1"
onclick="this.form.total.value=2;"></td>
<td valign=top>I eat breakfast.
</tr>

<tr>
<td align=center valign=top><input type="radio" name="2"
onclick="this.form.total.value=0;"></td>
<td align=center valign=top><input type="radio" name="2"
onclick="this.form.total.value=1;"></td>
<td align=center valign=top><input type="radio" name="2"
onclick="this.form.total.value=2;"></td>
<td valign=top>I eat lunch.</td>
</tr>

<tr>
<td colspan=4>Your score is: <input type="text" name="total"
readonly onFocus="this.blur();"></td>
</tr>

</table>

</form>

</body>
Jul 23 '05 #1
2 1397
no*@this.time wrote:
Hello All,

I am trying to develop a relatively simple self-quiz form in
javascript, but I'm having no luck getting it to work.

What I am looking for is a script that allow the user to select one of
three answers for each question, and automatically assign a value to
their answer ("never"=0, "sometimes"=1, "always"=2). There would be
anywhere from ten to thirty questions. ...


http://www.mickweb.com/javascript/fo...tedSurvey.html
Mick
Jul 23 '05 #2
not
On Thu, 06 Jan 2005 21:50:53 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
http://www.mickweb.com/javascript/fo...tedSurvey.html


Amazing. Thank you VERY much.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
4
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to...
2
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
0
by: tbatwork828 | last post by:
If you were like me trying to figure out how to launch context sensitive help topic by the context id, here is the link: http://weblogs.asp.net/kencox/archive/2004/09/12/228349.aspx and if...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.