• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A loop for this script? A challenge for me!

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have been trying to find a solution for a while...
Basically, I have a dhtml menu script which is hard coded and works well but I want to use a for loop to make it more elegant. However I have tried many different tricks without success.

My main problem is that I can not pass any value to



This is the url for the file where you can see the javascript.

test


This is the use case senario:

1. User moves the mouse over "tutorial" on the top menu bar, the submenu for "tutorial" pops up.

2. User moves mouse away from "tutorial", the submenu disappear in 1 second.

3. User moves mouse down from "tutorial" to the popped submenu area, the submenu will stay visible.

4. User moves mouse away from the submenu, the submenu disappears in 1 second.

5. The submenu should either appear all the way to the left of the menu bar or all the way to the right of the menubar after crossing a curtain point.

Please help.
[ July 05, 2005: Message edited by: Richard Vagner ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do not need quotes if the id is the string.
The code below is passe in a string with the id of an element. It toggles its display based on the state.



Eric
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Eric for your reply. However, the problem is not "quote" or not "quote" because I tried all of them. The main problem I can not pass the value to getElementById() in the following code with quote or not quote:
This drags me for a while and I can not find a solution.


[ July 05, 2005: Message edited by: Richard Vagner ]
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am just wondering if it is really possible to pass any value to getElementById(). I even tried

f="tutorial";
document.getElementById(f).on_mouse_over=function(){} and it is still not working! I do not what I am missing!
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like this:



Eric
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,

Based on your idea, I tried something like the following. But the value still not passed.

Thanks a lot


Here
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be probably doing something like this:

document.getElementById(xID).onmouseover = new Function("clearTimeout(TIMER);document.getElementById('" + xID + "').style.visibility='visible';");
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You should be probably doing something like this:

document.getElementById(xID).on_mouse_over = new Function("clearTimeout(TIMER);document.getElementById('" + xID + "').style.visibility='visible';");



Eric,
Based on your suggestion, I came up with:

function AddHandlers(xID){
document.getElementById(xID).on_mouse_over = new Function("clearTimeout(TIMER);document.getElementById('" + xID + "').style.visibility='hidden';");
document.getElementById(xID).on_mouse_over = new Function("TIMER=setTimeout(document.getElementById('" + xID + "').style.visibility='visible', 500)");

}


However, the above code is not working.
1. It complains that TIMER is not defined.
2. Even when I removed clearTimeout(TIMER) portion the code is still not doing what I expected. Basically, when the mouse is over the submenu it is supposed to stay visible but it is not.
3. I have a hard time to make setTimeout work:
document.getElementById(xID).on_mouse_over = new Function("TIMER=setTimeout(document.getElementById('" + xID + "').style.visibility='visible', 500)");

It complains that visible is not defined. I do not know why.

See Complete Code Here

Thanks a lot.
 
Crusading Chameleon likes the size of this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic