Announcement

Collapse
No announcement yet.

Advice re Javascript left hand nav

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Advice re Javascript left hand nav

    Hi all

    I am getting closer with my continuing quest for a new left hand nav but would apprecaite some guidance re. javascript.

    I am trying to add an additional level of drilldown to my existing lefthand nav but I cant get it to work.

    Basically I have amended original code and amended the By Product > Cufflinks section in (Act_LeftHandNav_inliveSept2006.htm) to have a couple of sub-options. This is in Act_LeftHandNav_newcufflinksTABLE.htm. However as soon as I click on the cufflinks button, instead of expaning the new cufflinks sub-categories/links, the By Product category closes!

    Can anyone see what I may have done wrong?

    Kind regards

    Paul
    KJ BECKETT
    Attached Files
    KJ Beckett
    Men's Clothing & Accessories
    Cufflinks, Underwear, Ties, Grooming Products
    Bath, England
    Fast delivery to UK, USA and worldwide.
    Men's Fashion Blog

    #2
    I'm not a JS expert and I might be wrong, but I think the problem is that every time the page is drawn, the variable, menuState, is re-initialised. It doesn't retain its value between pages. This code fragment shows the effect. Paste it into a file called test.html and try it on your PC.

    Code:
    <HTML>
    <HEAD>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    var menuState = -1;
    function test()
    {
    	var s = new String();
    	menuState++;
    	s = "menuState = " + menuState + "<br>";
    	document.write(s);
    }
    //-->
    </script>
    
    </HEAD>
    
    <BODY>
    <script language="JavaScript">
    <!--
    	test();
    // -->
    </script>
    <a href="test.html">Test</a>
    </BODY>
    </HTML>

    Comment


      #3
      Ah, of course.

      Yes - so everytime I refresh the page with the menu open, the menu closes on the new page ... and clicking on the new cufflinks button has the same affect - e.g. it goes back to square one.

      Hmmm - so I need improved Javascript. Thanks for your advice Alan.

      Paul
      KJ Beckett
      Men's Clothing & Accessories
      Cufflinks, Underwear, Ties, Grooming Products
      Bath, England
      Fast delivery to UK, USA and worldwide.
      Men's Fashion Blog

      Comment


        #4
        You should store any between page information in cookies. There should be plenty of tutorials on the 'net regarding this.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Great thanks Norman. I am not so concerned about the fact the navigation bar closes between pages (altough it may be a usability enhancement I can make in the future).

          The actual desired functionality is to 1) click on a navigation link once - to open a list of links or sub options - then 2) to click on one of the sub options - to open another list of links. At the moment, when I click on the second (2) set of options it closes the navigation bar. Would this require cookies despite the functionality not being between pages?

          At the moment my thinking is that I need multiple menuStates?

          Paul
          KJ Beckett
          KJ Beckett
          Men's Clothing & Accessories
          Cufflinks, Underwear, Ties, Grooming Products
          Bath, England
          Fast delivery to UK, USA and worldwide.
          Men's Fashion Blog

          Comment


            #6
            No cookies needed. You may need separate state variables for each menu level.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment

            Working...
            X