You need to get the current value of the select element when the select change event fires:
$(".myselect").change(function(){ $(".search").val( $(this).val() ); });
Online demo: http://jsbin.com/apuba/edit
Note that this method does not require the addition of event-logic onblur or onfocus to your HTML code. Instead, it will be related in itself if you give it adequate selectors.
<input type="text" name="search" class="search" /> <select class="myselect" name="foo"> <option>100</option> <option>200</option> <option>300</option> </select>
HTML doesn't need anything else.
Update
To do this, you can link several drop-down menus. Suppose you have the following:
<select id="product_1"> </select> <select id="product_2"> </select>
You can associate both of them with the following:
$("#product_1, #product_2").change(function(){ $(".search").val( $(this).val() ); });
Note that I am adding new dropdowns just by changing the selector.
source share