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 to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Boxes - more than 2 boxes possible?

    Hello together,

    is it possible to create more than 2 boxes with the javascript "CUT & PASTE DOUBLE COMBO"? My target is a produktfinder, therefore our visiter have to answer in the first step 4 questions, than he get the right produkt.

    It would be nice to hear from you - tanks for help!

    Greatings
    Chris

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Not a million miles from here:-

    http://www.javascriptkit.com/script/...plecombo.shtml

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    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,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You'd do better to use select lists rather than combo boxes for product selection - that way they have to select a product you actually have rather than being able to type anything they like into the combobox.
    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
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by felgall View Post
    You'd do better to use select lists rather than combo boxes for product selection - that way they have to select a product you actually have rather than being able to type anything they like into the combobox.
    I understood that the questioner desired select lists, which is what the script I mentioned provides.

    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.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Philip M View Post
    I understood that the questioner desired select lists, which is what the script I mentioned provides.
    I realise that. The point I was trying to make is that there is a difference between a select list and a combo box. The person asking the question was asking about completelty the wrong form element.

    The HTML for a select list and the HTML for a combo box are completely different apart from both having option tags to define the pre-defined options you can select from.

    Select List:

    Code:
    <select name="statesel" id="state">
    <option value=" " selected="selected"> </option>
    <option value="ACT">ACT</option>
    <option value="NSW">NSW</option>
    <option value="NT">NT</option>
    <option value="QLD">QLD</option>
    <option value="SA">SA</option>
    <option value="TAS">TAS</option>
    <option value="VIC">VIC</option>
    <option value="WA">WA</option>
    <option value="OS">overseas</option>
    </select>
    Combo Box:

    Code:
    <input type="text" list="state">
    <datalist id="state">
    <option value="act">
    <option value="nsw">
    <option value="nt">
    <option value="qld">
    <option value="sa">
    <option value="tas">
    <option value="vic">
    <option value="wa">
    </datalist>
    Also they function quite differently (with these examples you'd have to select 'overseas' from the select list if you don't want to select an Australian state whereas with the combo box you'd simply enter the name of the state you are in instead of selecting it). So it is difficult to understand how pople can possibly get the two confused.
    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
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by felgall View Post
    I realise that. The point I was trying to make is that there is a difference between a select list and a combo box. ...
    Combo Box:

    Code:
    <input type="text" list="state">
    <datalist id="state">
    <option value="act">
    <option value="nsw">
    <option value="nt">
    <option value="qld">
    <option value="sa">
    <option value="tas">
    <option value="vic">
    <option value="wa">
    </datalist>
    So it is difficult to understand how pople can possibly get the two confused.
    The <datalist> tag is new in HTML5, the term "combobox" isn't. The term and its functionality may well have been in long-term use with other languages.

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    I am afraid that I have always considered double combo and multiple (double) select lists as synonyms.

    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 to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello again,

    thanks for your help.

    Philip M: Thanks for your link, i will try it at first with 3 opportunitis for our visitors. Perhaps it is better so, becouse 4 boxes also take extremly much work.

    Have a good time.

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by ChLi View Post
    Hello again,

    thanks for your help.

    Philip M: Thanks for your link, i will try it at first with 3 opportunitis for our visitors. Perhaps it is better so, becouse 4 boxes also take extremly much work.
    Yes, extremly much work! But perfectly possible of course.

    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
    New Coder
    Join Date
    Jan 2011
    Posts
    52
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by ChLi View Post
    Hello together,

    is it possible to create more than 2 boxes with the javascript "CUT & PASTE DOUBLE COMBO"? My target is a produktfinder, therefore our visiter have to answer in the first step 4 questions, than he get the right produkt.
    If you find array-building too imponderable, you could evaluate this script: http://scripterlative.com/files/selectcascade.htm, which in the event that you cannot use a server-side database, lets you use XML blocks to store/retrieve the option data.

  • #11
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Logic Ali View Post
    The <datalist> tag is new in HTML5, the term "combobox" isn't. The term and its functionality may well have been in long-term use with other languages.
    Yes. HTML 5 is introducing the missing combo box form field into web pages. It has been available in other programming languages used for creating desktop applications since the introduction of Windows 3.0 (from my personal knowledge) and possibly a lot earlier.

    The whole reason why it has always been called a combo box is because it COMBINES the functionality of an input field and a dropdown list into a single form field.

    When I first started writing web pages back in 1999 the combo box field was one that I could see several uses for but where there was at that time no easy way to implement it. The only way was to display two fields where JavaScript updated the input field if something was selected in the select list. The introduction of the DOM made it possible to use JavaScript to combine an input field and a list to produce a combo box that works with JavaScript enabled and which appears as just an input field when JavaScript isn't available. HTML 5 is finally introducing a way to create a combo box using just HTML - something that should have been added to HTML at the same time the <form> tag was added - since all other languages had combo box elements available to use in forms.

    A combo box is DEFINITELY NOT a synonym for a drop down list as a drop down list only provides half the functionality of a combo box.

    The term combo box for a combination of input field and dropdown list into a single form field long predates the introduction of the web - it is just that the web hasn't provided an easy way to define a combo box prior to HTML 5.
    Last edited by felgall; 11-06-2012 at 08:31 PM.
    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.

  • #12
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by felgall View Post
    Yes. HTML 5 is introducing the missing combo box form field into web pages. It has been available in other programming languages used for creating desktop applications since the introduction of Windows 3.0 (from my personal knowledge) and possibly a lot earlier.

    The whole reason why it has always been called a combo box is because it COMBINES the functionality of an input field and a dropdown list into a single form field.

    When I first started writing web pages back in 1999 the combo box field was one that I could see several uses for but where there was at that time no easy way to implement it. The only way was to display two fields where JavaScript updated the input field if something was selected in the select list. The introduction of the DOM made it possible to use JavaScript to combine an input field and a list to produce a combo box that works with JavaScript enabled and which appears as just an input field when JavaScript isn't available. HTML 5 is finally introducing a way to create a combo box using just HTML - something that should have been added to HTML at the same time the <form> tag was added - since all other languages had combo box elements available to use in forms.

    A combo box is DEFINITELY NOT a synonym for a drop down list as a drop down list only provides half the functionality of a combo box.
    OK, but HTML5 is still some way from implementation and it will be quite a few years before HTML4 browsers are extinct.

    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.

  • #13
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Philip M View Post
    OK, but HTML5 is still some way from implementation and it will be quite a few years before HTML4 browsers are extinct.
    As I said, since the introduction of the DOM it has been possible to create a combo box using an input field and a list using HTML 4 - see http://javascriptexample.net/domform11.php

    Prior to the introduction of the DOM the closest you could get (for browsers such as Netscape 3 and 4) was to use both an input field and a dropdown list and link them together - http://javascript.about.com/library/blnav7.htm shows how I created combo box fields in web forms back in 2002 through 2005.

    I'd been using combo boxes in desktop applications in the early 1990s and so that such an element hasn't existed in HTML prior to HTML 5 is something that I have always found to be annoying - hence the above two solutions that I implemented in my forms.
    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.


  •  

    Posting Permissions

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