Skip to content

Instantly share code, notes, and snippets.

@victorhazbunanuff
Last active December 20, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorhazbunanuff/6186411 to your computer and use it in GitHub Desktop.
Save victorhazbunanuff/6186411 to your computer and use it in GitHub Desktop.
Copy and reflect values from an element to another
function ReflectValueOnKeyUp(from, to, options) {
var options = options || {};
var escape_string = options.escape_string || false;
$(from).keyup(function(){
var that = $(this);
if (options.escape_string == true) {
$(to).val(escapeString(that.val()));
} else {
$(to).val(that.val());
}
});
}
:javascript
ReflectValueOnKeyUp('#account_name', '#account_domain', {escape_string: true});
ReflectValueOnKeyUp('#account_admin_attributes_first_name', '#account_billing_information_first_name');
ReflectValueOnKeyUp('#account_admin_attributes_last_name', '#account_billing_information_last_name');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment