+ Reply to Thread
Results 1 to 7 of 7

Thread: javascript

  1. #1
    rick8028 is offline x10Hosting Member rick8028 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    5

    javascript

    I am going to insert an html javascript code, the script works, but I want the menus hidden on page load.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html xmlns="http://www.w3.org" xml:lang="en">
    
    <head>
    
    <title> The Pool Gods </title>
    <script type="text/javascript">
    function toggle(list){
    var listElementStyle=document.getElementById(list).style;
    if (listElementStyle.display=="none"){
    listElementStyle.display="block";
    }
    else {
    listElementStyle.display="none";
    }
    }
    </script>
    
    </head>
    
    <body>
    
    
    
    
        <a href="javascript:toggle('menu')">Getting Started</a><br>
    <ul id="menu">
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods">Home</a></font></li>
        
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/home/freeSignUp/">Free Sign-Up</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/home/howToPlay/">How To Play</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/home/rules/">Rules</a></font></li>
        </ul>
        
    </ul>
    
    <a href="javascript:toggle('menu2')">Standings</a><br>
    <ul id="menu2">
    
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/standings/dailyBuzz/">Daily Buzz</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/standings/hallOfFame/">Hall Of Fame</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/standings/formalChallenge/">Formal Challenge</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/standings/reportLoss/">Report A Loss</a></font></li>
        </ul>
    
    </ul>
    
    <a href="javascript:toggle('menu3')">Tournaments</a>
    <ul id="menu3">
    
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/tournaments/tourneyBuxLog/">Tourneys Bux Log</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/tournaments/tourneyAwards/">Awarded Medals</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/tournaments/tourneyRibbons/">Tourney Ribbons</a></font></li>
        <li><font color="red" font size="5"><a href="http://www.myleague.com/thepoolgods/tournaments/overview/">Over View</a></font></li>    
        </ul>
    
    </ul>
    
    
    
    
    
    
    
    </body>
    
    </html>
    I can't seem to figure it out, Thanks in advance

  2. #2
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: javascript

    Not too sure this will work, but calling onload="toggle()" should hide the list.

    so, change <body> to

    Code:
    <body onload="toggle()" >
    and see what happens. =]
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  3. #3
    rick8028 is offline x10Hosting Member rick8028 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    5

    Re: javascript

    That didn't work, they do collapse when clicked, but the sub-menu items are still visible, those should be hidden, I got this code off a tut, I changed variable to toggle rather than switchit, that's what they had for the variable.. It didn't work with switchit neither.. Any other ideas we can try?

  4. #4
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: javascript

    Note: I'm not great at javascript, but this *might* work:

    I can't figure it out, been trying for ten minutes. :x

    Here's my idea (like I said, i'm not good with JS)

    <body onload="toggle('menus')">

    Then, the function would contain an array containing all the names of the menus you wish to close. Then:

    if(listElementStyle.display=="menus"){
    }

    inside that, the thing would have a function that sets all the values in the array to
    listElementStyle.display="none";

    Understand what I'm saying?

    That's basically your PsuedoCode, figure it out from there.

    Sorry I couldn't help more. =/
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  5. #5
    rick8028 is offline x10Hosting Member rick8028 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    5

    Re: javascript

    Well, I forgot to mention, this was an older javascript script I found online, maybe it got removed? Other than that, I have no idea... I am fairly new to JS, I'm better with HTML/CSS than anything else, so this scripting stuff is pretty foreign to me, LOL...

  6. #6
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: javascript

    All you need to do is change
    <ul id="menu">
    <ul id="menu2">
    <ul id="menu3">
    to
    <ul id="menu" style="display:none;">
    <ul id="menu2" style="display:none;">
    <ul id="menu3" style="display:none;">
    Last edited by VPmase; 05-31-2009 at 12:15 PM.

  7. #7
    rick8028 is offline x10Hosting Member rick8028 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    5

    Re: javascript

    Ttytyty VPMase, it's working now!

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 08-17-2008, 01:46 AM
  2. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  3. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  4. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  5. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers