简体   繁体   中英

HTML form data to Google sheets

I have a html form , google form and a google sheet .

When I hit submit, I need the data from the html form' to be submitted into the google sheet`.

I took the form tag from the google form and pasted it to the html form as follows :

 <form action="https://docs.google.com/forms/d/e/1FAIpQLSdrPC9AHgQPtBWPJ4nOVVF1Nqxf3IgpSGVjqs7NpkDRPjgQQQ/formResponse" target="_self" method="POST" id="gbgform">

But when I hit submit, the only thing that is saved in the google sheet is the timestamp, no data.

I appreciate any solution that will make this happen.

Thank you!!

I know I'm a little late on this, but currently, this is the best way to do it. Let's say you want to have four questions in your html form to link to the spreadsheet. Make a google form with those questions and the click view (don't do it in the editor) and view the source. Do Ctrl + f and find

A: The form action (make sure to use post)

B: VERY IMPORTANt . Do CTRL F again and look for the name of the questions. Look for the name entry. and some random numbers. There should be one for every questions. Then make your form with the form action the link you copied and the name of each question with the name of the question you copied (remember the entry.?).

*Note: If you don't want to redirect to google forms (Your response has been submitted) add this iframe:

iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted) {window.location='aftersignup.html';}"></iframe> iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted) {window.location='aftersignup.html';}"></iframe> *

Then set the target of the form like this

<form action="YOUR ACTION" method="post" target="hidden_iframe" onsubmit="submitted=true;">

Full Code:

<form action="YOUR_ACTION_HERE" method="post" target="hidden_iframe" onsubmit="submitted=true;">
    <h1> Register Your School </h1>

    <fieldset>



      <label for="name">School Name:</label>
      <input type="text" id="name" name="entry.1493342091">

      <label for="email">School Email:</label>
      <input type="email" id="mail" name="entry.958733922">

      <label for="password">School Size:</label>
      <input type="number" id="password"       name="entry.427827738">


    </fieldset>
    <fieldset>  

      <button type="submit">Register</button>

   </form>

If you noticed that the form redirects to aftersignup.html . You could put that as any link. Once you made the form, go back the form and click "Create Spreasheet".

Hope this helped!

I did this by following the video here . You can do it by using the input IDs from a pre-made form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM