Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu loading function

Status
Not open for further replies.

Vormav

Programmer
Jun 21, 2002
12
US
Hi. I'm a bit new to javascript, so go easy on me. ;)
I'm trying to form a function to handle menu loading, since I think I'm going to have a lot of menus. Here's the header stuff:
Code:
last_menu = "opening_menu";
		
function load_menu(menu) {
top.frames[0].last_menu.style.visibility="hidden";
top.frames[0].menu.style.visibility="visible";
last_menu = menu;
}

Then you'd call the function with events like onClick="load_menu('different_menu')"
The idea is that the last_menu variable stores the last menu that was accessed, so that the function knows which menu to turn hidden upon loading another, and then updates the last_menu variable with the current menu loaded. Since no events call the function upon loading, I set the variable as 'opening_menu' to give the starting menu.
Except that is giving me an 'object expected' error wherever the function is called. I'm guessing it's just something with my syntax, but I don't know how to work js syntax with cases like this. Another strange thing, when I added this function and an event caller to my page, other completely unrelated events started returning 'object expected' errors as well, even when the events were never triggered. Don't know what that's about, but I'm guessing fixing this would fix that.
 
its being treated as a string cos you pass it in in quotes, you yould just eval it as such:

last_menu = "opening_menu";

function load_menu(menu) {
eval("top.frames[0]."+last_menu+".style.visibility='hidden'");

eval("top.frames[0]."+menu+".style.visibility='visible');
last_menu = menu;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top