jquery - How to set the phone number in hidden field, and then get that hidden value and set it on changing the dropdown -
i want autofill integer field phone number of users whenever thier name selected in dropdown.i have jquery onchange function(of dropdown)where both values in same page , can , set value anywhere in page using jquery.but code not applicable in case because phone number diplayed field in other page , dropdown in page.the field autofilled in same page of dropdown.now how phone number of corresponding users selected dropdown.
below juery code
<%= javascript_tag %> $(document).ready(function() { $("#issue_custom_field_values_119").change(function() { var seloption = $(this).val(); var test = $("table.person tr td.phones").text(); alert(test); $("#phones").val(parseint($("#num-" + seloption).text())); }); }); <% end %>
<html> <head> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script> $(document).ready(function () { $('select').change(function () { $(this).val($('#phone').val()) }); }); </script> </head> <body> <select name="car" id="select"> <option value="1">999</option> <option value="2">888</option> <option value="3">777</option> <option value="4">555</option> </select><input type="hidden" value="4" id="phone"/> </body> </html>
Comments
Post a Comment