File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

Global variable doesnt work

Sven Bender
Greenhorn

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.

Thanks!

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
okay, what is this l.onclick(); doing? calling a js function or hitting the server?
 
GeeCON Prague 2014
 
subject: Global variable doesnt work