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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop Down Menu With Iframes

    Im Still kinda new to Scripts etc So please be nice

    Basically i want a simple drop down menu (like that dreamweaver creates) That lets me open the links into the iframe

    Ive searched around and cant seem to solve the problem ???

    Thx in advance for you help guys!

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    This should work.

    Code:

    \\This one goes to the site when the user changes the dropdown menu.

    <html>
    <head>
    <script language="javascript">

    function formhandler(form){
    var URL = document.form.site.options[document.form.site.selectedIndex].value;
    window.content.location.href=URL;
    }

    </script>
    </head>
    <body>
    <form name="form">
    <select name="site" onchange="formhandler(form);">
    <option>Select A Site. . .
    <option value="http://www.codingforums.com">Coding Forums
    <option value="http://www.msn.com">MSN
    <option value="http://www.yahoo.com">Yahoo
    </select>
    </form>
    <iframe src="" name="content" height=450 width=800></iframe>
    </body>
    </html>

    \\This one goes when you click on the button

    <html>
    <head>
    <script language="javascript">

    function formhandler(form){
    var URL = document.form.site.options[document.form.site.selectedIndex].value;
    window.content.location.href=URL;
    }

    </script>
    </head>
    <body>
    <form name="form">
    <select name="site">
    <option>Select A Site. . .
    <option value="http://www.codingforums.com">Coding Forums
    <option value="http://www.msn.com">MSN
    <option value="http://www.yahoo.com">Yahoo
    </select>
    <input type="button" value="go" onclick="formhandler(form)">
    </form>
    <iframe src="" name="content" height=450 width=800></iframe>
    </body>
    </html>

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thx for that , and it works

    Is it also Possible to have the menu in the main window , but to open in an iframe i have already made?????

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Yes just put the javascript code in the head of the document. and then set your naming convention the same as what is here ie. name your iFrame "content",your form "form" and your select box "site".

  • #5
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi,

    <html>
    <body>
    <form name="form">
    <select name="site" onchange="if (this.selectedIndex != 0)content.location=this.options[this.selectedIndex].value">
    <option>Select A Site. . .</option>
    <option value="http://members.aol.com/grassblad>GrassBlade Javascript</option>
    <option value="http://www.webxpertz.net/forums>webXpertz Forums</option>
    <option value="http://www.google.com">Google</option>
    </select>
    </form>
    <iframe src="" name="content" height=450 width=800></iframe>
    </body>
    </html>

    Vinny
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

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