Javascript

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJavascript

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old June 9th, 2013, 02:24 PM
cjackson111 cjackson111 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 9 cjackson111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 52 m 36 sec
Reputation Power: 0
Resetting a variable to "0"

Hello. I am developing an iPhone quiz app using HTML5, JavaScript and CSS. I have run into a snag. When correct answers are chosen the score goes up by 1 point. This works great however when someone wants to start a new quiz (I have it set to go back to the home screen when the "New" button is clicked on), the old score still shows up. I am not sure how to reset the score.

I have tried passing the variable as "0" in the url to the page that starts the quiz but that does not work.

Code:
<a href="#page2?currentValue=0">Start Quiz</a>


Also, after it is passed, what will I need to do to update the actual value? The code below is what I am using to keep score.

Code:
 var currentValue = 0;
         var add = function(valueToAdd){
        currentValue += valueToAdd;
        document.getElementById('number').innerHTML = currentValue;
    };



Thanks for all help!

Reply With Quote
  #2  
Old December 30th, 2013, 01:09 AM
vijay_kumar123 vijay_kumar123 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 2 vijay_kumar123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m
Reputation Power: 0
solution

Quote:
Originally Posted by cjackson111
Hello. I am developing an iPhone quiz app using HTML5, JavaScript and CSS. I have run into a snag. When correct answers are chosen the score goes up by 1 point. This works great however when someone wants to start a new quiz (I have it set to go back to the home screen when the "New" button is clicked on), the old score still shows up. I am not sure how to reset the score.

I have tried passing the variable as "0" in the url to the page that starts the quiz but that does not work.

Code:
<a href="#page2?currentValue=0">Start Quiz</a>


Also, after it is passed, what will I need to do to update the actual value? The code below is what I am using to keep score.

Code:
 var currentValue = 0;
         var add = function(valueToAdd){
        currentValue += valueToAdd;
        document.getElementById('number').innerHTML = currentValue;
    };



Thanks for all help!




reload the page with javascript function . it will reset the page with new values . that's all you want..

virtual punjabi keyboard

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJavascript > Resetting a variable to "0"


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap