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.
|
|
|
|
|
![]() |
||
Need help on an onclick function
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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 |
|
|
|
|||
|
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. |
|
|||
|
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...
|
![]() |
| Tags |
| form test, onclick |
| Thread Tools | |
|
|
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 |