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 13 of 13
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    47
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Looking for a all browsers compatible combo box

    Hello,

    I have search the net looking for a combo box compatible with all browsers without any luck.
    I want a Combo Box that takes action (open an url in a new window) after the user select the appropriated category.

    The ones that i have found works in IE, OP and Chrome but not on Mozilla.

    Can anyone post or point me to any direction?

    Thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Quote Originally Posted by tribalmp View Post
    Hello,

    I have search the net looking for a combo box compatible with all browsers without any luck.
    I want a Combo Box that takes action (open an url in a new window) after the user select the appropriated category.

    The ones that i have found works in IE, OP and Chrome but not on Mozilla.
    Really? What do you mean by a combo box? Do you mean a select list? Why do you say your code does not work in Mozilla(Firefox)?

    Code:
    <select id = "mysel" onchange = "goThere()">
    <option value = 0 >Choose...</option>
    <option value = 1 >Coding Forums</option>
    <option value = 2 >Javascript Kit</option>
    <option value = 3 >Google</option>
    </select>
    
    <script type = "text/javascript">
    
    function goThere() {
    var val = document.getElementById("mysel").value;
    if (val == 1) {var dest = "http://www.codingforums.com"}
    if (val == 2) {var dest = "http://www.javascriptkit.com"}
    if (val == 3) {var dest = "http://www.google.com"}
    window.location.href = dest;
    }
    
    </script>

    Yes, but did you see the unseen work of Calum Clark? - Presenter, Radio Northampton
    Last edited by Philip M; 03-27-2014 at 03:48 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by Philip M View Post
    Really? What do you mean by a combo box? Do you mean a select list?
    Presumably he means a COMBO BOX since select lists work in all browsers while combo boxes were only introduced into HTML with version 5.

    A combo box written in HTML should work in all modern browsers including Firefox and will only fail in older versions of IE.

    To support older browsers you'd create a combo box using an <input type="text" and a list. The one I have at Combo Box was written quite a while ago but did work on all the popular browsers that were around at the time it was written and should work on the more modern versions of those browsers as well.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,880
    Thanks
    6
    Thanked 1,035 Times in 1,008 Posts
    Wikipedia has the definition: https://en.wikipedia.org/wiki/Combo_box

    For me, a combo box was also similar to a select element but apparently I wasn’t correct with my assumption.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Combo boxes have been a common form field element for several decades - everywhere but on web pages where it got left out when all the form field types were originally defined. HTML 5 has rectified that omission.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Same with VIPStephan, I thought a <select> tag was also known as a combo box or a dropdown. I think that's common for people in general. Presumably because there is really no real combo box control in HTML that people interchangeably call a select as combo box or dropdown.

    @tribalmp, post your code.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Quote Originally Posted by VIPStephan View Post
    Wikipedia has the definition: https://en.wikipedia.org/wiki/Combo_box

    For me, a combo box was also similar to a select element but apparently I wasn’t correct with my assumption.
    As Wikipedia says, "Today, the original distinction between a combo box and a drop-down list has often disappeared".

    I would agree with glenngv. But Stephen says "The combination of being able to select from a list or type it yourself is why this particular form field is referred to as a combo box." On reflection I am sure he is right, although I don't think I have ever encountered one of these.
    Last edited by Philip M; 03-28-2014 at 11:34 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #8
    New Coder
    Join Date
    Oct 2008
    Posts
    47
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Let me rephrase, i'm looking for a select list that open in a new window. (_blank, _new)

    @Philip M
    The code you post uses window.location.href and this open in the same window

    The code that i'm using is below:
    <script type="text/javascript">
    function Go(objCombo)
    {
    var strUrl=objCombo.options[objCombo.selectedIndex].value;
    if (strUrl.length < 2)
    return false;

    var arrTmp=strUrl.split("*");
    window.open(arrTmp[0], (arrTmp.length == 1)?"_self":"_blank", "height=1000,width=1200");
    }
    </script>
    <select name="DropMenu" onchange="Go(this);">
    <option value="#" selected disabled=disabled>-- Please select: --</option>
    <option value="http://www.site.com*">Site 1</option>
    <option value="http://www.site2.com*">Site 2</option>
    </select>

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Which of the three places (new window, new tab, same tab) web pages open is completely under the browser's owner's control. You can only suggest where it should open in your code and the browser can be set to ignore your suggestion and open it where the browser owner wants it to open.

    Your visitor is supposed to be the one deciding what opens where - that's why the target attribute was made obsolete in 1997.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by tribalmp View Post
    Let me rephrase, i'm looking for a select list that open in a new window. (_blank, _new)

    @Philip M
    The code you post uses window.location.href and this open in the same window

    The code that i'm using is below:
    I tried your code in Chrome and Firefox and it works in both browsers. I wonder why you said it is not working in Firefox. Maybe you have a popup blocker in Firefox that blocks the popup?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #11
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Try this:-

    Code:
    <select id = "mysel" onchange = "goThere()">
    <option value = 0 >Choose...</option>
    <option value = 1 >Coding Forums</option>
    <option value = 2 >Javascript Kit</option>
    <option value = 3 >Google</option>
    </select>
    
    <script type = "text/javascript">
    
    function goThere() {
    
    var winWidth = 1200;
    var winHeight = 800;
    var winLeft = (screen.width-winWidth)/2;
    var winTop = (screen.height-winHeight)/2;
    var winOptions = ",width=" + winWidth;
    winOptions += ",height=" + winHeight;
    winOptions += ",left=" + winLeft;
    winOptions += ",top=" + winTop;
    winOptions += ",resizable=yes";
    winOptions += ",scrollbars=1";
    
    var val = document.getElementById("mysel").value;
    if (val == 1) {var dest = "http://www.codingforums.com"}
    if (val == 2) {var dest = "http://www.javascriptkit.com"}
    if (val == 3) {var dest = "http://www.google.com"}
    //window.location.href = dest;  // same window
    maxWindow = window.open(dest, "newWindow", winOptions);  // new window
    maxWindow.focus();
    }
    
    </script>

    But I would still recommend opening the page in the same window. Pop-up blockers may block a new window from opening.
    Last edited by Philip M; 03-29-2014 at 01:54 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #12
    New Coder
    Join Date
    Oct 2008
    Posts
    47
    Thanks
    6
    Thanked 2 Times in 2 Posts
    @glenngv
    Doesn't work with Firefox using TOR.

    @Philip M
    Thanks for the code

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Then maybe that TOR addon or software is keeping your script from working. Try disabling that.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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