1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Javascript help

Discussion in 'BBS Hangout' started by Chuck04, Aug 8, 2002.

  1. Chuck04

    Chuck04 Member

    Joined:
    Feb 15, 1999
    Messages:
    815
    Likes Received:
    233
    I'm assuming that it would be Javascript used to do this, but what I want to try and do is to have like a navigation menu for a website. Now in that nav menu there would be say 6 entries. When a user clicks on one of these links, a subset of menues would appear and give another bunch of links. Then if the users clicked one of the original 6 links, that submenu would disappear and the submenu from that other link would appear. Something like the following:

    Link1
    Link2
    Link3
    Link4
    Link5
    Link6

    Now if the user clicked on Link1, then the nav menu would look something like (with thos submenus indented slightly):

    Link1
    Sublink1
    Sublink2
    Sublink3
    Link2
    Link3
    Link4
    Link5
    Link6

    Then if the user clicked Link4, it would change to:

    Link1
    Link2
    Link3
    Link4
    Sublink1
    Sublink2
    Link5
    Link6

    If the user clicked on one of the Sublink's then it would load that page in another frame, or would load the page in the current window (if I wasn't using frames)

    Anyone know how this can be done?

    BTW, the submenus won't neccessarily have the same amount of links, ie Link1 may have 4 links in the submenu, Link3 may have 2, Link 6 may have 5 etc. etc.
     
  2. Jeff

    Jeff Clutch Crew

    Joined:
    Feb 14, 1999
    Messages:
    22,412
    Likes Received:
    362
    What you are talking about is DHTML or Dynamic HTML. That allows you to open menus like the one's you mention.

    There are tons of reference books and websites on DHTML. You can also create those using an editor like Macromedia Dreamweaver.

    You could conceivable do this with a mouseover graphic using javascript but I think the DHTML would be easier. You can also accomplish the same thing with Flash if necessary.
     
  3. DCkid

    DCkid Member

    Joined:
    Oct 15, 2001
    Messages:
    9,661
    Likes Received:
    2,706
    Well, what you're talking about is pretty tough to do in JavaScript. Different browsers have their own quirks when it comes to Javascript, and you can spend about as much time figuring out a solution as you can just trying to get the page working on Netscape 4, Netscape 6, and Internet Explorer. The easiest thing would just be to reload a frame containing the menu with the sublinks depending on which link the user clicked. That means if you had four links, you would need to create four html pages with each page listing the sublinks for one of the links. I know that's not really very smooth and frames can have their own problems, but that's all I can tell you. Maybe someone else has a better idea. There is a way to do it in Javascript by using using something called "layers," but that could end up getting really messy. What you're talking about is more suited for Java applets. Sorry, I couldn't be of more help.
     
  4. Chuck04

    Chuck04 Member

    Joined:
    Feb 15, 1999
    Messages:
    815
    Likes Received:
    233
    OK, thanks Jeff, DCKid. Looks like I'll have to re-install Flash then. I kind of knoew it could be done with Javascript, but didn't realise it would have been that difficult.
     
  5. Johnny Rocket

    Johnny Rocket Member

    Joined:
    Jan 12, 2000
    Messages:
    1,725
    Likes Received:
    0
    you could start with this one from dynamic drive and then tweak it to suit you needs.
     
  6. Chuck04

    Chuck04 Member

    Joined:
    Feb 15, 1999
    Messages:
    815
    Likes Received:
    233
    Perfect. Exactly what I was looking for. Thanks JR.
     
  7. ChenZhen

    ChenZhen Member

    Joined:
    Aug 20, 2000
    Messages:
    1,779
    Likes Received:
    43
    Chuck, for future reference...for the best javascript codes go here: <a href="http://javascript.internet.com/">http://javascript.internet.com</a>

    That's how I started...Don't just copy and paste, try to understand the code...it will help you in the long run because javascript will be here to stay for a long while...
     

Share This Page