Jayita Roy Jayita Roy - 1 year ago 65
PHP Question

Textbox and Dropdown Control - jQuery, PHP

I want to type for example "ABCD" in the textbox and immediately dropdown list will show the value "ABCD". Kindly help me.

Answer Source

If i understand your question then you need to add input field value in select list options you can do it like below

 <input name="option" type="text" id="option">
    <select id='mySelect'>
    <option value="">--Select--</option>
    <option value="default">default</option>
    </select>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>
    $('input').on('change', function(event) {
         var option = $('#option').val();
    	if(option){
    	 $('#mySelect').append( '<option value="'+option+'">'+option+'</option>' );
      }
    });
    
    </script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download