简体   繁体   English

HTML 表单数据到 Google 表格

[英]HTML form data to Google sheets

I have a html form , google form and a google sheet .我有一个html formgoogle formgoogle sheet

When I hit submit, I need the data from the html form' to be submitted into the google sheet`.当我点击提交时,我需要将来自html form' to be submitted into the的数据html form' to be submitted into the谷歌表中。

I took the form tag from the google form and pasted it to the html form as follows :我从google form获取表单标签并将其粘贴到html form ,如下所示:

 <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.但是当我点击提交时, google sheet唯一保存的是时间戳,没有数据。

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.假设您希望在 html 表单中有四个问题以链接到电子表格。 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 findCtrl + f并找到

A: The form action (make sure to use post) A:表单动作(一定要使用post)

B: VERY IMPORTANt . B:非常重要 Do CTRL F again and look for the name of the questions.再次按CTRL F并查找问题的名称。 Look for the name entry.查找名称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: *注意:如果您不想重定向到 google 表单(您的回复已提交),请添加此 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> * 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 .如果您注意到表单重定向到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.您可以使用预制表单中的输入 ID 来完成此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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