To populate multiple textboxes when a DropDownList value is selected using jQuery or Javascript -
i want populate multiple textboxes value of selected dropdownlist (select list) using jquery. here code have
the jquery script <script type="text/javascript"> $("#item").change(function () { $("#txtbox").val($(this).val()); }); </script>
the drop down <select name="item" id="item"> <option value="1">orange</option> <option value="2">apple</option> <option value="3">grapes</option> </select> them html text boxes <input type="text" name="name" id="txtbox" /> <input type="text" name="name" id="txtbox" /> <input type="text" name="name" id="txtbox" /> , on....
from codes when select dropdown first textbox populated. want textboxes populated value of selected dropdown
id must unique. change use classes , should work:
$("#item").change(function () { $(".txtbox").val($(this).val()); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select name="item" id="item"> <option value="1">orange</option> <option value="2">apple</option> <option value="3">grapes</option> </select> <input type="text" name="name" class="txtbox" /> <input type="text" name="name" class="txtbox" /> <input type="text" name="name" class="txtbox" />
Comments
Post a Comment