Just thought I would post this little jQuery snippet which simply updates the value of input field based on value of another. This can be particularly useful in some situations where information can be duplicated for example perhaps on a billing and shipping address form etc.
Example for standard text based input field:
$(“#src-field”).change(function () {$(“#otherfield”).val($(“#src-field”).val());}).change();
Example for select field:
$(“#src-select”).change(function () {$(“#otherfield”).val($(“#src-select option:selected”).val());}).change();
The Select version will used the selected value, if you would like to get the text of the option you can replace .val() with .text().
Hope this helps someone, would appreciate a quick comment if you use it!
[ad name=”posts”]
Facebook Comments