Create a gist now

Instantly share code, notes, and snippets.

Easily fill out web forms using data from a spreadsheet using this bookmarklet.

To set this up, paste the code below into the "location" of a bookmark. Make sure it starts with "javascript:", some browsers strip this out when you paste.

  1. Find the "name" of each form element you want to put data into. You can find the "name" by right clicking on the form box and "inspecting" it.
  2. By using a spreadsheet, create a set of urls with the data you want to input. Example: variablename1 is the "name" of the form field. "value1" is the value you want to put into the box.www.website.com/page.html?variablename1=value1&variablename2=value23. Navigate to that custom URL4. Click the bookmarklet. Voila!
javascript: function getUrlVars() {
var vars = [],
hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
function ParamsIntoForms(get) {
for (var i = 0; i < get.length; i++) {
if (document.getElementsByName(get[i]).length != 0) {
document.getElementsByName(get[i])[0].value = decodeURIComponent(get[get[i]]);
}
}
return false;
}
var get = getUrlVars();
ParamsIntoForms(get);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment