This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Global variable doesnt work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Global variable doesnt work" Watch "Global variable doesnt work" New topic

Global variable doesnt work

Sven Bender

Joined: May 24, 2005
Posts: 2
Hello there!

Im currently writing a webapplication with JSF and Javascript. I have a navigation menu on the left which should also be usable by pressing keys like "1" or "a". The menu has 3 entries in the root with 4 subentries each. My Javascript works fine for the root elements, but when it comes to the submenus something goes wrong. If the user pressed for instance "1" which means he will be in the first submenu i want to save this state for later use. What i did is : I declared a variable outside my function var state = 0; inside my code i refer to that variable by state = 1; but for some reason the value of state isnt changed. It remains 0 which makes the rest of my script not working. Below is the whole source of my script. Hopefully someone can help.


[edit- fixed code layout - Eric]
[ May 25, 2005: Message edited by: Eric Pascarello ]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
okay, what is this l.onclick(); doing? calling a js function or hitting the server?
I agree. Here's the link:
subject: Global variable doesnt work
Similar Threads
hardcoding in javascript
Date is automatically trimming in ie9,chrome and firefox
Scope Chain / Closures
Multiple Select box Problem
Page section does not update after call of a4j:support in IE 9