473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

JavaScript Counter

Hello guys,

I'm trying to do JS counter and I have found the thread here: http://bytes.com/topic/javascript/answers/153258-increase-displayed-variable-after-clicking-button

The problem is, that when I refresh page the counter is reset.

What I want ideally is this:

Counter starts at 0, when the button is pushed the first time, the counter goes to 1. When the button is pushed the second time, the counter goes to 2, and similary to 3. When the button is pushed the 4th time the counter should go back to 0.

Thank you very much!
Mar 29 '12 #1
3 2035
Rabbit
12,516 Expert Mod 8TB
Javascript values do not carry through a page reload. If you need to retain the value, you need to either store it in a cookie, store it in a session variable using server side scripting or store it in a database using server side scripting.
Mar 29 '12 #2
Thanks for your reply!
I'm a total newbie at this, do you maybe have some examples of the options you suggested - session variables...? I'd grately appreciate it.

Thanks!
Mar 30 '12 #3
Rabbit
12,516 Expert Mod 8TB
First you have to pick and learn a server side scripting language. But be sure to install that scripting engine on the web server. If your web host doesn't have it and won't allow it to be installed, then you're out of luck on the server scripting front.
Mar 30 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jim in Arizona | last post by:
I've been looking for a counting script to count the number of hits to my HTM and asp web pages on my company's internal website. So far, everything I've seen only works on asp pages. Where would I...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
6
by: Geoff | last post by:
Here's the situation. I have a static html page which we want to update to include some dynamic content. I want a counter that keeps track of the number of times anyone presses the "add" button,...
4
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
9
by: brett | last post by:
I'd like to execute javascript if I'm in a certain directory. I can't figure out how to render the javascript script below. I always end up with some type of parsing error. Any suggestions? ...
4
by: srinpraveen | last post by:
I badly want to know if there is a way in javascript to just a create a variable and increment it each time a particular visits the page. In other words, I want to use this as a counter for counting...
1
by: houssam_ballout | last post by:
hello all I am new to JavaScript, I want some help in creating a script that will count down (in a box), the number of seconds that I will enter it into anther text box thanks
12
by: devospice | last post by:
Hi, I'm trying to create a download counter for individual files on a web site and I'm not sure how to do this. Right now I'm using Webalizer to just read the log files and see how many times...
4
HawkNail
by: HawkNail | last post by:
Long story short, I'm making an online test to help prepare some buddies for an online math test. The test is timed and so I am trying to put in a counter to count down to zero. My code looks like...
1
by: Gino Dicandio | last post by:
Hello, I actually use a counter on a webpage (This is an external script that reads and increments a value - It actually works) To do it, I use an inline javascript but I would like to unify the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.