Skip to content

Instantly share code, notes, and snippets.

@benubois
Created November 5, 2010 02:19
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 benubois/663548 to your computer and use it in GitHub Desktop.
Save benubois/663548 to your computer and use it in GitHub Desktop.
Populate: JavaScript form field populator
var fields = {
'email': {
'value': 'example@example.com',
'aka': ['email', 'email_address', 'emailAddress']
},
'first_name': {
'value': 'First Name',
'aka': ['first_name', 'firstName', 'first', 'firstname']
},
'last_name': {
'value': 'Last Name',
'aka': ['last_name', 'lastName', 'last', 'lastname']
},
'password': {
'value': 'passw0rd',
'aka': ['password', 'text_password']
},
'confirm_password': {
'value': 'passw0rd',
'aka': ['confirm_password', 'confirmPassword', 'confirmpassword']
},
'phone': {
'value': '5555555555',
'aka': ['phone', 'phone_number', 'phoneNumber']
},
'company': {
'value': 'Company',
'aka': ['company', 'companyName']
},
}
$.each(fields, function(index, value) {
for (var i = value.aka.length - 1; i >= 0; i--){
$('input[name=' + value.aka[i] + ']').val(value.value);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment