Need some Java Script Help

Discussion in 'OT Technology' started by IAMwhitey, Nov 28, 2005.

  1. IAMwhitey

    IAMwhitey New Member

    Joined:
    Nov 8, 2001
    Messages:
    1,010
    Likes Received:
    0
    Location:
    Pittsburgh, PA
    This is the first time I ever worked with Javascript. So far I am doing decent but I can not figure out one piece of the code. I was wondering if some of you that are more familiar with JS could shed some light.

    here is the code I am working with:

    Code:
    <script language="JavaScript">
    <!--
    function Show_Stuff(Click_Menu)
    // Function that will swap the display/no display for
    // all content within span tags
    {
    if (Click_Menu.style.display == "none")
    {
    Click_Menu.style.display = "";
    }
    else
    {
    Click_Menu.style.display = "none";
    }
    }
    -->
    </script>
    
    <table border="0" cellpadding="0" style="border-collapse: collapse" width="100%">
    <tr>
    <td width="100%">
    <img border="0" src="Themes/button_themes/Sunrise_Red/header-browse-cat_l.gif" alt="Category">
    </td>
    </tr>
    	<tr>
    		<td align="left" valign="top" width="100%">
    
    <DIV><a class="navbar" href="javascript:Show_Stuff(display2)">Nissan</a></DIV>
    <span ID="display2" style="display: none">
    <table>
    <tr><td width=100% wrap>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=5">Specials</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=6">New Items</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=7">Motorsets/Swaps</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=8">Package Deals</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=9">OEM Parts</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=10">Engine Parts</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=14">Intakes</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=11">Intercoolers / BOV</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=12">Exhaust</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=13">Fuel System</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=16">Turbo Upgrades</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=17">Cooling Parts</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=18">Electronics/Guages</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=19">Brakes</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=20">Suspension</a></br>
    <a class="navbar" href="index.asp?PageAction=VIEWCATS&Category=21">Transmission/Drivetrain</a></br>
    </td>
    </tr>
    </table>
    </span>
    
    </td>
    	</tr>
    </table>
    
    Right now onload it displays Nissan as a category, when you click on Nissan it displays all of the subcategories. Now when I click a subcategory I would like for the subcategories to stay open instead of closing like they do now.

    Any help would be great! Thanks

    cliff notes: noob to JS can not figure out how to keep his subcategory menu open when a subcategory is chosen. kthnx
     
  2. mace

    mace i don't read

    Joined:
    Jun 6, 2004
    Messages:
    12,567
    Likes Received:
    0
    Location:
    Texas
    when you click the link a new page is displayed, so the script starts all over again.
    you should remove the inline style in the sub category page so the category menu isn't closed when the page is loaded.
     
  3. IAMwhitey

    IAMwhitey New Member

    Joined:
    Nov 8, 2001
    Messages:
    1,010
    Likes Received:
    0
    Location:
    Pittsburgh, PA
    thanks for your quick response, but if you remove that piece by default it would always be open.
     

Share This Page