One Click Submit a Google Form
The process below will allow you to submit a google form by clicking a single link. Documenting because I never seem to remember.
Initial steps:
- Get the id of the form, located after the
/d/e
portion of the Form URL - Grab the
textarea name
from the Google Form page source. I normally do a manual searchentry.
and find the form field name from there.
The "New" Google Forms would show
<!-- formatted for readability -->
<input type="text"
class="quantumWizTextinputPaperinputInput exportInput"
jsname="YPqjbf"
autocomplete="off"
tabindex="0"
aria-label="Enter Your Age"
aria-describedby="i.desc.1524225339 i.err.1524225339"
name="entry.1366940499"
value=""
dir="auto"
data-initial-dir="auto"
data-initial-value=""/>
Click to see the textarea of the "old" Google Forms
<textarea name="entry.1366940499"
rows="8"
cols="0"
class="ss-q-long"
id="entry_1366940499"
dir="auto"
aria-label="Enter your age"
aria-required="true"
required="">
</textarea>
- In the above example, you need the value of
name
.- In the "New" Google Forms example above, this value is
entry.1366940499
- Be sure to only use the value of the
name
parameter, not theid
ori.desc
- In the "New" Google Forms example above, this value is
- Once you have collected all of the
entry
fields, you may begin to construct the url: - Base URL snippet:
https://docs.google.com/forms/d/e/FORMID/formResponse?&[entry.number=value]&submit=SUBMIT
- Replacing
FORMID
,entry
, andvalue
, you have a url that will submit a form when used withcurl
(bash),UrlFetch
(Google Apps Script), or pasted into your browser.
A live example
- Click the link above to submit the form, or do the following:
- Copy the link and paste it into the address bar in your browser or text editor
- Edit the url to change the value of
entry.244206211
to any value of your choosing- NOTE: Editing the url in Microsoft Word or Excel will cause the form to submit three times. Not sure why, but I will update when I have more information (thanks for letting me know!)
- Hit Enter to submit the form
- View your submission in the responses sheet, linked below
- View the form responses here
Auto Submit A Form
Be Advised: This may not be the best method.
A simple javascript fetch()
command can be used to automatically submit the form on page load using something like <body onload="submit(answer)">
.
function submit (answer) {
answer = encodeURIComponent(answer)
var formId = '1FAIpQLScJqX5YrRP8Q6sQsx3dCvTjwkv0byizdD2_IvJM5i2CAz-GPw'
var queryString = 'formResponse?&entry.244206211=' + answer + '&submit=SUBMIT'
var url 'https://docs.google.com/forms/d/e/' + id + queryString
var opts = {
method: "POST",
mode: "no-cors", // apparently Google will only submit a form if "mode" is "no-cors"
redirect: "follow",
referrer: "no-referrer"
}
return fetch(url, opts)
}
This comment has been minimized.
Been looking for a solution for this for a while, Thank you!
Will update if works for me