Need help on an onclick function

This is a discussion on "Need help on an onclick function" within the JavaScript Forum section. This forum, and the thread "Need help on an onclick function are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 27th, 2007, 20:38
New Member
Join Date: Jan 2007
Location: somewhere
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Need help on an onclick function

Hello,
I am quite new to javascript and I am creating a form test, and basicly what I want it to do is there will be many questions and when the user answers one question correctly and presses the submit button, I want to add one to they're total score then continue to the next problem.

I dont really have any script to show you because the script that I have is very cluttered and needs reorganizing.

So if theres anyone that could help me with this I would be very grateful.

DaveKenroy
Reply With Quote

  #2 (permalink)  
Old Jan 28th, 2007, 02:26
New Member
Join Date: Jan 2007
Location: somewhere
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on an onclick function

I have reorganized my script and have something to show you what I mean.

Oh and by the way, the reason I do not use the submit button is because when it submits, it also refreshes. So as far as I know, when it refreshes all the values return to they're original state.

<script type="text/javascript" language="javascript">
<!--
var totalcorrect = 0
var x = totalcorrect + 1
function validateform01( ) {
if (document.form01.radio01[0].checked || document.form01.radio01[1].checked || document.form01.radio01[3].checked) {
alert("Incorrect! The correct answer was 4. Click OK to continue to the next problem.")
}
if (document.form01.radio01[2].checked){
var totalcorrect = x
alert("Correct! Click OK to continue to the next problem." + calculatetotalcorrect( ))

}
}
function swap(obj,newsrc) {
obj.src = newsrc;
}
//-->
</script>

<body>
<A HREF="#question2"><IMG SRC="image1.gif" NAME="image" BORDER="0" onclick="validateform01( )"></A>
</body>

Last edited by DaveKenroy; Jan 28th, 2007 at 02:32.
Reply With Quote
  #3 (permalink)  
Old Jan 28th, 2007, 07:30
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help on an onclick function

Using cookies would probably be the best way to go about this. Just do a quick Google search for JavaScript cookies and you'll get all the info you need
Reply With Quote
  #4 (permalink)  
Old Jan 28th, 2007, 11:31
Reputable Member
Join Date: Jul 2006
Location: Scotland
Age: 22
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to snow
Re: Need help on an onclick function

Cookies might be a bit overkillish for a problem like this - could you just store the total correct in a GET or POST (although GET might be a little prone to some cheating if it wasn't encrypted lol)? Retieve it every page and add to it depending on the outcome...
Reply With Quote
Reply

Tags
form test, onclick

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnClick Behaviour Monie JavaScript Forum 3 Oct 23rd, 2007 02:13
createEmptyMovieClip & onclick R Verbrugge Flash & Multimedia Forum 7 Sep 13th, 2007 15:34
Problem: onClick Function mihirc Web Page Design 16 Jul 28th, 2007 11:20
problem calling function via onClick Eagle JavaScript Forum 5 Jan 15th, 2007 21:41
onclick function tomd1985 JavaScript Forum 0 Mar 13th, 2006 18:20


All times are GMT. The time now is 23:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43