Skip to content

Instantly share code, notes, and snippets.

Last active October 14, 2022 00:07
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save caseywatts/5952495 to your computer and use it in GitHub Desktop.
Save caseywatts/5952495 to your computer and use it in GitHub Desktop.
Easily fill out web forms using data from a spreadsheet using this bookmarklet.

Other gists & tricks:

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 Navigate to that custom URL4. Click the bookmarklet. Voila!
javascript: function getUrlVars() {
var vars = [],
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[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();
Copy link

Casey, this rocks! I just got this to work. Thank you!
To help the next person who looks at this and struggles with it, here are a couple tips:
--Once you've created the bookmarklet, then create the URL like Casey describes. Here's an example of one I got to work: and then run your bookmarklet. You can try it with mine, and it works!
--If you're unfamiliar with bookmarklets, check out Casey's tutorial on bookmarklets:
--and for those who are visual learners, here's a video for you! I'm not a coder, so if you're not a coder either, take comfort that you'll get a non-coding explanation of what's going on.

Enjoy, and thanks again Casey!

Copy link

kibkib commented Feb 8, 2021

Thanks. This is useful.
It did not work for me when there were reserved characters in the element name.

! | # | $ | & | ' | ( | ) | * | + | , | / | : | ; | = | ? | @ | [ | ]
%21 | %23 | %24 | %26 | %27 | %28 | %29 | %2A | %2B | %2C | %2F | %3A | %3B | %3D | %3F | %40 | %5B | %5D

I had to change it like this:

            if (document.getElementsByName(dcd).length != 0) {
                document.getElementsByName(dcd)[0].value = decodeURIComponent(get[get[i]]);
               //also I fire an onchange event of the changed element as the form i need to fill requires it


Copy link

psthampi commented Feb 26, 2021

For text fields like first name and last name and date of birth it works fine
Is there any extra code for radio buttons in this case for sex of patient.
example for male patient i tried
It does not work

Any advise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment