javascript - how to select select2 using another select2 values -
i have 2 select2 input boxes, requirement if selected 1 select2 box value effect select2 box.
my code below:
<input class="select2-offscreen itemid_0" type="text" name="itemid" id="itemid[]" style="width:100px; left:297.5px !important; top:863px !important; float:left !important" tabindex="-1" onchange="display();"> <input class="select2-offscreen unitid_0" type="text" name="unitid" id="unitid[]" style="width:100px; left:297.5px !important; top:863px !important; float:left !important" tabindex="-1"> <script> function display(){ $(".unitid_0").select2("val","hr"); } </script>
please tell me did mistake?
thanks, madhuri
you mean value in both boxes should same, right?
$(function () { $(".itemid_0").keyup(function () { // on key in first box var value = $(this).val(); // value $(".unitid_0").val(value); // set value of second box }); });
Comments
Post a Comment