select_option

I have a drop-down list with certain values ​​(from the database). Question: How to do if there is no value that I need, then I must enter the values ​​myself. For example, there is no red, I have to write the word red there.

    4 answers 4

    http://htmlbook.ru/html/datalist
    http://caniuse.com/#feat=datalist

    http://jsfiddle.net/3zdjntco/

    <input list="colors-list"> <datalist id="colors-list"> <option value="Blue"></option> <option value="Brown"></option> <option value="Orange"></option> </datalist> 

      The method given here earlier is good. But as an alternative, I would advise using js on the user side: it gives you more opportunities to play around with the look of it all.

      Option a) Add <option value="Custom"></option> , when selected, a field so hidden <input name="Custom" value=""/> appears where a person can enter the desired value (on the PHP side, so you can add processing, something like $color = ($_GET['colorlist']=="Custom")? $_GET['Custom'] : $_GET['colorlist'];

      Option b) The issuing list is generally implemented on js (for example, arranging a list of <ul><li></li></ul> , where values ​​from the database will be loaded), and drive the result of the selection into a hidden input field. - then, to enter an arbitrary value, you can drive at least in the menu itself ( <ul><li>Red</li><li>...</li><li><input name="Custom" value=""/></li></ul> )

        Add this to the menu of choice in the database, if the menu is pulled from the base, or directly into the html code, if the menu is pulled from the page itself.

        • ))) Thanks for the answer, this method does not roll - qwerty

        You can, for example, use the following option: add the "Not in the list" option to the list; when you select it, display an additional input field where you can enter any value with your hands.