+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: select onchange

  1. #1
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    select onchange

    I am looking to use the code below on my website but I have not been able to figure out how to open the links in a new window. I do not mind if I have to use another language. If anyone can help me out I would highly appreciated.

    Thanks

    Code:
    <form action="" id="sites">
    <select name="sites" onchange='top.location.href=this.form.sites.options[this.form.sites.selectedIndex].value'> 
    
    <option value="#">Select the site</option>
    <option value="http://www.website1.com">website1</option>
    <option value="http://www.website2.com">website2</option>
    <option value="http://www.website3.com">website3</option>
    
    </select>
    </form>
    Last edited by driveflexfuel; 10-22-2008 at 04:18 PM.

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: select onchange

    I've figured a way to produce a jump menu with target = blank.

    Shove this in your <head>

    Code:
    <script type="text/javascript">
    function MM_jumpMenuNewWindow (selObj, restore) {
        window.open(selObj.options[selObj.selectedIndex].value);
        if (restore) selObj.selectedIndex=0;
    }
    </script>
    Then the form

    Code:
    <form action="" id="sites">
      <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenuNewWindow(this,0)">
        <option value="#">Select a Site</option>
        <option value="http://www.website1.com">website1</option>
        <option value="http://www.website2.com">website2</option>
        <option value="http://www.website3.com">website3</option>
      </select>
    </form>
    I've tested it and it works.

  3. #3
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: select onchange

    or
    Code:
    <select name="sites" onchange='window.open(this.form.sites.options[this.form.sites.selectedIndex].value)'>
    correct me if i'm wrong, but isn't MM_jumpMenuNewWindow a dreamweaver code snippet? i'm not attacking you if it is a dreamweaver snippet, but i am personally getting annoyed with people posting dreamweaver snippets... whatever happened to learning how to code, instead of using a program giving you a wizard and making code from that? another thing, the code snippet is more complex than the other code above.

    again, i'm not attacking you, just pointing out a general trend going on...
    Last edited by xPlozion; 10-22-2008 at 04:51 PM.

  4. #4
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    Re: select onchange

    Freecrm that code would work but it throws all kinds of flags when using IE. I don't want my customers to have to click allow popups to view the content.

    xPlozion That was exactly what I needed thanks
    Last edited by driveflexfuel; 10-22-2008 at 04:44 PM.

  5. #5
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: select onchange

    np, dreamweaver tends to make things more complicated than they need to be.
    Last edited by xPlozion; 10-22-2008 at 04:56 PM.

  6. #6
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: select onchange

    This link might be what you are looking for:

    http://www.pageresource.com/jscript/jwinopen.htm

  7. #7
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: select onchange

    Quote Originally Posted by xPlozion View Post
    or
    Code:
    <select name="sites" onchange='window.open(this.form.sites.options[this.form.sites.selectedIndex].value)'>
    correct me if i'm wrong, but isn't MM_jumpMenuNewWindow a dreamweaver code snippet? i'm not attacking you if it is a dreamweaver snippet, but i am personally getting annoyed with people posting dreamweaver snippets... whatever happened to learning how to code, instead of using a program giving you a wizard and making code from that? another thing, the code snippet is more complex than the other code above.

    again, i'm not attacking you, just pointing out a general trend going on...
    Part of this is a DW snippet but as anyone knows who uses DW, it doesn't let you have target="_blank".

    The script provided is an adaptation of the snippet to provide new window functionality.

    It was just faster to do!

  8. #8
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: select onchange

    i am aware that it doesn't let you use target blank, but at the same time, not does xhtml strict :P. i've been using that for a few years now, and have found basic ways to get around these minor issues.

    for example, instead of using
    Code:
    <a href='http://www.x10hosting.com' target='_blank'>x10Hosting</a>
    I would use
    Code:
    <a href='http://www.x10hosting.com' onclick='return externalUrl(this.href)'>x10Hosting</a>
    and in my javascript functions file, i've got:
    Code:
    function externalUrl (href) {
      window.open(href);
      return false;
    }
    the return false would prevent the browser following that a href link in the current window, instead open it, leaving the current page in tact. if the user has javascript disabled, it would just follow the current link in the same tab/window ;)

    again, not attacking you, but some of the things dw does, and many web designers do is down right sloppy (including huge sites, such as gamespot, xbox.com, etc...)

  9. #9
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: select onchange

    Quote Originally Posted by xPlozion View Post
    again, not attacking you, but some of the things dw does, and many web designers do is down right sloppy (including huge sites, such as gamespot, xbox.com, etc...)
    No offence taken. I've only been developing for about 12 months so I am stretched between having to reach deadlines and understanding what I'm doing!

    I've generally found that now I'm reaching the limits of what DW can achieve, I'm starting to learn! ;)

    Maybe I should go back to notepad!

  10. #10
    quantum1's Avatar
    quantum1 is offline x10Hosting Member quantum1 is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    near Nashville, TN
    Posts
    68

    Re: select onchange

    No freecrm! Don't do it!!!

    Go with http://www.ultraedit.com


+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. I can't select the database!
    By offres in forum Free Hosting
    Replies: 1
    Last Post: 04-02-2008, 02:24 PM
  2. MySQL SELECT Question
    By Synkc in forum Programming Help
    Replies: 3
    Last Post: 02-09-2008, 03:51 PM
  3. I can't select my textarea.
    By Yvette in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 10-30-2007, 10:24 AM
  4. How to create a current year to 1900 select box.
    By Brandon in forum Tutorials
    Replies: 5
    Last Post: 12-27-2006, 12:40 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