-
Update variables onclick
Hi I have simple int variable in javascript.
I want to change it's value when I click on some link.
How can I do it?
Thanks!
Last edited by d-machine; 10-21-2009 at 10:48 PM.
-
-
There is no such thing (technically speaking) as a simple variable. The closest thing would perhaps be a global variable. If that's what you have, it can be changed in an onclick event without much trouble. Let's say, as could be construed from your post, that the name of this variable is int:
Now, of course, if this is a link, one should return false.
In the above I've set it to the number 5. It could just as easily be set to a string, boolean, object, etc.
But, even with a global, if it has already been put into another scope, depending upon the situation (like as part of an interval), though its value will change, its value in the interval will not.
If it is not a global, unless it has some way of being referenced from the global scope (like being a part of an object in the global scope), you might not be able to access it from an onclick event.
So if you are still having problems, please be more specific and post a link to your page where this is an issue.
Last edited by jscheuer1; 10-22-2009 at 04:44 AM.
Reason: be more precise
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks