Skip to content

Instantly share code, notes, and snippets.

@maxcal
Created October 11, 2011 08:35
Show Gist options
  • Save maxcal/1277583 to your computer and use it in GitHub Desktop.
Save maxcal/1277583 to your computer and use it in GitHub Desktop.
Autofill donation form.
var data = {
forename: "Test",
surname: "Testsson",
addressone: "Vintergatan 1",
postcode: 5555,
phone: "055-555555",
email: "test@testsson.com",
city: "Ingenstans"
};
(function(data){
var field, input, form;
form = document.forms['donationform'];
for (key in data) {
if (data.hasOwnProperty(key)) {
input = form.elements[key];
input.value = data[key];
}
}
return "Done!";
}(data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment