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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to connect anchors to drop-down-list?

    In the HTML below I would like to add anchor1, anchor2 and anchor3 to the choices choice1, choice2 and choice3. Can anyone help?

    This is the HTML:
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <meta name="generator" content="Adobe GoLive 4">
    <title>Welcome to Adobe GoLive 4</title>
    </head>

    <body>
    <select name="select1" size="140" length="3">
    <option VALUE="choice1" SELECTED>Choice1
    <option VALUE="choice2" SELECTED>Choice2
    <option VALUE="choice3" SELECTED>Choice3
    </select>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br><br>
    <br>
    <br><br>
    <br>
    <br><br>
    <br>
    <br><br>
    <br>
    <br>
    <a name="anchor1"></a>Here is Anchor1<br>
    <br>
    <a name="anchor2"></a>Here is Anchor2<br>
    <br>
    <a name="anchor3"></a>Here is Anchor3<br>
    </body>

    </html>

    Kippie

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this?
    Code:
    <html>
    <head>
    <title></title>
    </head>
    <body> 
    <form action=""><select name="warp" onchange="top.location.href =this.form.warp.options[this.form.warp.selectedIndex].value" size="140" length="3"> 
    <option value="" selected="selected">Choose</option>
    <option value="#anchor1">Choice1</option> 
    <option value="#anchor2">Choice2</option> 
    <option value="#anchor3">Choice3</option></select></form> 
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <a name="anchor1"></a>Here is Anchor1<br><br> 
    <a name="anchor2"></a>Here is Anchor2<br><br> 
    <a name="anchor3"></a>Here is Anchor3<br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </body> 
    </html>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this:

    <select onchange="window.location=this.value;">
    <option value="#anchor1">Choice 1</option>
    <option value="#anchor2">Choice 2</option>
    <option value="#anchor3">Choice 3</option>
    </select>

    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <a name="#anchor1"></a>1<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <a name="#anchor2"></a>2<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <a name="#anchor3"></a>3<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>


    not sure what browsers it will work in, only tested in IE6

    Edit: beaten... should have refreshed the page after testing the script... ah well...
    redhead

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks guys,

    This helps! Now I changed the HTML (see below) and it goes fine. The only problem is that the listbox opens with "choice3" instead of "choose". Can that be changed also?

    This is my new HTML:

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <meta name="generator" content="Adobe GoLive 4">
    <title>Welcome to Adobe GoLive 4</title>
    </head>

    <body>
    <a name="#up"></a>
    <br>
    <form name="ListBoxForm">
    <p><select SIZE="1" NAME="ListBoxURL" onchange="location.hash=this[this.selectedIndex].value;">
    <option value="" selected="selected">Choose</option>
    <option VALUE="anchor1" SELECTED>Choice1
    <option VALUE="anchor2" SELECTED>Choice2
    <option VALUE="anchor3" SELECTED>Choice3
    </select>
    </form>
    <br>
    <a name="anchor1"></a>Here is Anchor1<br>
    <a href="#up">Back-UP</a>
    <br>
    <a name="anchor2"></a>Here is Anchor2<br>
    <a href="#up">Back-UP</a>
    <br>
    <a name="anchor3"></a>Here is Anchor3<br>
    <a href="#up">Back-UP</a>

    </body>
    </html>

    Kippie

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try replacing this (selecting all options...):

    <option value="" selected="selected">Choose</option>
    <option VALUE="anchor1" SELECTED>Choice1
    <option VALUE="anchor2" SELECTED>Choice2
    <option VALUE="anchor3" SELECTED>Choice3

    with this:

    <option value="" selected="selected">Choose</option>
    <option VALUE="anchor1">Choice1</option>
    <option VALUE="anchor2">Choice2</option>
    <option VALUE="anchor3">Choice3</option>

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great, thanks!

    Kippie

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Has anyone noticed when you click on a selection and it goes to the anchor, you scroll your wheelmouse thinking it's the page and instead, the selection box you just clicked on scrolls taking you to a new location?
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

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