Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [HELP] Javascript change style.display problem with unnecessary multiple clicks.

    Hey Everyone. I'm new here and I'm far from great with Javascript. Anyway, after many uneventful hours of trying to find a pre-built tree navigation system that was as simple as what I wanted I decided that (like always) it'd probably be best to spend the time and whip something up myself. So I scavenged around and put this together. http://extstudios.com/new/ (see the left bar). Now, It works great but it has a 1 minor problem.

    If you click back and forth between Section 1 and Section 2 sometimes you have to click two times to make the which ever section expand/contract. Its easier if you just try it. Go to the link above and start clicking back and forth between section 1 and section 2. You'll see what I mean. So the question is, how to get rid of this extra click non-sense. Thanks everyone!

    --Casey

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're using a single variable state to save/set the display state of your divs. Two divs one state variable...what happens when the state variable matches the state of last menu change, but not the state of the currently clicked menu?

    Either: use an array of state variables; or (better) don't try to store the state--have your onclick function check fetch the current contents of the display property and act accordingly.

    BTW, eval( "document.all." + layer_ref + ".style.display = state"); is horrible ugly and slow. Try document.all[layer_ref].style.display = state;

  • #3
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Harry! Workin on it now.

  • #4
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And its fixed! Thanks again Harry!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •