On Tue, Apr 15, 2008 at 12:04 PM, Kasey Clark <[EMAIL PROTECTED]> wrote:
> Ok, so I am really bad at javascript, but I have to use it for a project for 
> my computer class. This is my project: I am creating a personality quiz 
> webpage. Each question has 4 different choices (each choice matches a 
> different personality trait). I have done the HTML part and have all the text 
> boxes where the user will put a number between 1 and 4 and the calculate 
> button. Now I have to do the javascript part. I need javascript to add up the 
> total of the 8 boxes(there are 8 questions) and have an alert pop up with 
> their score and their personality description. So if their score is between 
> 30 and 36 they have an outgoing personality, etc. Can anyone give me any 
> advice on how to calculate the total score? Thanks!

alert(document.getElementById('answer1').value +
document.getElementById('answer2').value +
document.getElementById('answer3').value +
document.getElementById('answer4').value);

this makes a couple of assumptions :)

one assumption is that the form fields have an ID attribute each.  if
they don't, you can reference them via
document.formname.fieldname.value

the other assumption is that all of the values are actually numeric.
there's a few ways to handle that... but let's see how far this gets
you first.

-- 
Evelyn the dog, having undergone further modification pondered the
significance of short-person behaviour in pedal depressed,
pan-chromatic resonance, and other highly ambient domains. "Arf," she
said.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/Javascript/message.cfm/messageid:5179
Subscription: http://www.houseoffusion.com/groups/Javascript/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.33

Reply via email to