css - Putting dropdown option in input bar -


so, have search bar , drop down menu:

<input placeholder="name search" name="sp_name" id="sp_name" class="btn-block"/>     <input type="submit" id="sp_search_submit" class="btn" value="search"> 

and

<select name="sp_name" id="sp_name" class="input-small btn-block">                                   <option value="" type="text"><?php _e('all names', 'my_site') ?></option>     <option value="steve" <?php selected('steve', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>>steve</option>     <option value="mike" <?php selected('mike', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>>mike</option>     <option value="sean" <?php selected('sean', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>>sean</option> </select> 

now, both "name search" bar , dropdown menu have same id of "sp_name".

in other words, results either inputting name or selecting 1 of options.

however these 2 separate parts , takes spaces shown below in image.

i trying add dropdown menu part of input search bar shown below.

enter image description here

so, can either choose type name or select 1 of choices 1 single bar.

i tried put <input> 1 of <select> option, didn't work.

how can achieve this?

try this;

you can use following reference mention @ below:

jquery autocomplete combobox

kendo autocomplete combobox

<html> <head>     <base href="http://demos.telerik.com/kendo-ui/autocomplete/index">     <style>html { font-size: 12px; font-family: arial, helvetica, sans-serif; }</style>     <title></title>     <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.common-material.min.css" />     <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.2.624/styles/kendo.material.min.css" />     <script src="http://cdn.kendostatic.com/2015.2.624/js/jquery.min.js"></script>     <script src="http://cdn.kendostatic.com/2015.2.624/js/kendo.all.min.js"></script> </head> <body> <select id="soptions" style="visibility: hidden">                                 <option value="steve" <?php selected('steve', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>steve</option>   <option value="mike" <?php selected('mike', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>mike</option>   <option value="sean" <?php selected('sean', isset($_get['sp_name']) ? $_get['sp_name'] : ''); ?>sean</option> </select> <script type="text/javascript"> var texts = []; var sel = document.getelementbyid('soptions'); (var i=0, n=sel.options.length;i<n;i++) {   if (sel.options[i].text) texts.push(sel.options[i].text); } </script>         <div id="example">             <div>                 <h4>choose user name:</h4>                 <input id="user" style="width: 25%;" />             </div>             <script>                 $(document).ready(function () {                     $("#user").kendoautocomplete({                         datasource: texts,                         filter: "startswith",                         placeholder: "select name...",                         separator: " "                     });                 });             </script>         </div> </body> </html> 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -