I'm looking for a way to take specific fields from a Google Form and input it into an html page.
<form>
<input id="email" type="text" placeholder="email address" value="email">
<button id="submit" type="submit">Submit</button>
</form>
When I click submit, I want that data to submit to a specific Google form.
Thanks
You can embed Google Forms from the desktop website. Go to Google Forms, open the form you want to embed and click the "send" button on the top right of screen. Adjust the height and width of the embed and click "copy" to copy the HTML code. You can then paste the code on your website or blog.
Embedding Google Forms Open the Google form. In the top right corner, click the "Send" button. In the window that opens, click the "< >" tab and then copy the entire iframe code from beginning to end (you might need to scroll over to capture it all).
If you want to build your own form, hosted separately from Google, and submit to a Google Form, you need to emulate the Google Form's POST request. First, you need to get the form data that's being sent to Google and then you need to submit it from your own page using AJAX.
To get the form data, open Chrome's Developer tools and click the Network tab. Then submit your Google-hosted form with dummy data. Click on the first item you see in the list - it should say "formResponse". Then you need to copy two things from the data on the right-hand pane: "Request URL" (where your own form will submit) and anything beginning with "entry." in the Form Data section (e.g., "entry.123456").
Next, build a form on your own page, and use AJAX to submit the data to Google. The way I've done it is to use jQuery to hijack the form submission so that your form doesn't try to submit to your own domain:
$('.my-form').on('submit', function() {
e.preventDefault();
$.ajax(
type:"POST"
url: "https://docs.google.com/forms/d/your-form-id/formResponse"
data: {
'entry.12345': $('.your-form-input').val()
}
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With