iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old January 27th, 2007, 05:38 PM   #1
New Member
 

Join Date: Jan 2007
Location: somewhere
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 DaveKenroy is on a distinguished road
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
DaveKenroy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 27th, 2007, 11:26 PM   #2
New Member
 

Join Date: Jan 2007
Location: somewhere
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 DaveKenroy is on a distinguished road
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; January 27th, 2007 at 11:32 PM..
DaveKenroy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 28th, 2007, 04:30 AM   #3
Elite Veteran
 
Ryan Fait's Avatar
 

Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough
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
Ryan Fait is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 28th, 2007, 08:31 AM   #4
Reputable Member
 

Join Date: Jul 2006
Location: Scotland
Age: 23
Posts: 355
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 snow is on a distinguished road
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...
snow is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
form test , onclick


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
problem calling function via onClick Eagle JavaScript 6 August 28th, 2009 04:38 PM
OnClick Behaviour Monie JavaScript 3 October 22nd, 2007 11:13 PM
createEmptyMovieClip & onclick R Verbrugge Flash and ActionScript 7 September 13th, 2007 12:34 PM
Problem: onClick Function mihirc HTML, XHTML and CSS 16 July 28th, 2007 08:20 AM
onclick function tomd1985 JavaScript 0 March 13th, 2006 03:20 PM


Search Engine Optimization by vBSEO 3.2.0 RC8