File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 15385
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
It's not a secret anymore!