Created
November 5, 2010 02:19
-
-
Save benubois/663548 to your computer and use it in GitHub Desktop.
Populate: JavaScript form field populator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fields = { | |
'email': { | |
'value': '[email protected]', | |
'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