Results 1 to 5 of 5

Thread: JS Drop down

  1. #1
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation JS Drop down

    I am creating a drop down menu with an ok (image) button. I have all that working and it works fine. My issue is that I am wanting it to go to an iframe. Here is the coding with valid address in it that i am using. Can someone see where I am messing up?

    <html>
    <head>
    <title>Dropdown Additional Links</title>
    </head>

    <body>

    <!-- **********OPTION LIST********** -->


    <form name="hop">

    <select name="choose">
    <option selected>Choose One</option>
    <option value="http://mousetrax.com" target="site">Mousetrax</option>
    <option value="http://yahoo.com" target="site">Yahoo</option>
    <option value="http://microsoft.com">Microsoft</option>
    <option value="http://personal-computer-tutor.com">Linda's Computer Stop</option>
    <option value="http://personal-computer-tutor.com/abc">ABC Newsletter</option>
    </select>
    <input type="image" src="go.png" width="20px" height="20px" onClick="location=document.hop.choose.options

    [document.hop.choose.selectedIndex].value;" value="GO!">



    </form>


    <iframe id="main" name="site" frameborder="2" width="100%" height="610px" src="images/logo.htm"></iframe>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <input type="image" src="go.png" width="20px" height="20px" onClick="frames.site.location.href=document.hop.choose.options[document.hop.choose.selectedIndex].value;" value="GO!">
    But some browsers may not be happy with that. So one could instead do:

    Code:
    <input type="image" src="go.png" width="20px" height="20px" onClick="document.getElementById('main').src=document.hop.choose.options[document.hop.choose.selectedIndex].value;" value="GO!">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Actually I tried both and they both just seem to reset the drop down options.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Sorry, I didn't realize you had a form. Without the form, what I had should work. With a form, you need to use the form's onsubmit event (working demo):

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Dropdown Additional Links</title>
    <style type="text/css">
    iframe {
    	width: 100%;
    	height: 610px;
    	border: 2px solid #000;
    }
    </style>
    </head>
    <body>
    <form name="hop" onsubmit="document.getElementById('main').src = this.elements.choose.value; return false;">
    <select name="choose">
    <option value="images/logo.htm" selected>Choose One</option>
    <option value="http://mousetrax.com">Mousetrax</option>
    <option value="http://yahoo.com">Yahoo</option>
    <option value="http://microsoft.com">Microsoft</option>
    <option value="http://personal-computer-tutor.com">Linda's Computer Stop</option>
    <option value="http://personal-computer-tutor.com/abc">ABC Newsletter</option>
    </select>
    <input type="image" src="go.png" width="20" height="20" alt="GO!">
    </form>
    <iframe id="main" src="images/logo.htm"></iframe>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Thank

    Thanks, that did work with my links that I added. I appreciate your assistance
    Last edited by GUIDesigner; 09-13-2010 at 11:25 PM.

Bookmarks

Posting Permissions

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