【发布时间】:2014-12-16 16:12:40
【问题描述】:
我的表单是 html 格式的。我从原始 Google 表单中复制了操作、输入键和隐藏输入。
<form id="Gform" role="form" action="https://docs.google.com/forms/d/MY-FORM-KEY/formResponse" method="POST" target="_self" onsubmit="">
<input type="text" pattern="^[a-zA-Z][a-zA-ZążźćśęółbńĄŻŹĆŃŚĘÓŁ ]{4,40}$" name="entry.1028663680" value="" id="entry.1028663680" dir="auto" title="What is Your city" class="form-control" placeholder="City" required>
<input type="text" pattern="^[a-zA-Z][a-zA-ZążźćśęółbńĄŻŹĆŃŚĘÓŁ ]{5,40}$" name="entry.1220908348" value="" id="entry.1220908348" dir="auto" title="Your complete name" class="form-control" placeholder="Your name" required>
<input type="tel" name="entry.623688995" value="" id="entry.623688995" dir="auto" title="" class="form-control" placeholder="phone" required>
<input type="email" name="entry.1564973803" value="" id="entry.1564973803" dir="auto" title="" class="form-control" placeholder="email" required>
<input type="hidden" name="entry.383122401" value="WEBSITE" id="entry.383122401" dir="auto" title="" class="form-control" placeholder="E-mail" required>
<input type="hidden" name="draftResponse" value="[,,"-9139933475238999509"]
">
<input type="hidden" name="pageHistory" value="0">
<input type="hidden" name="fbzx" value="-9139933475238999509">
<button type="submit" name="submit" id="sendData" class="btn btn-default">Submit</button>
</form>
我有一个 jQuery 脚本,它显示确认:
<script type="text/javascript">
function sendContactForm(){
$("#Gform").fadeOut();
$("#form-container").append('<p class="confirmer">Thanks!<br>Your email was sent.</p>');
};
$('#Gform').submit(function () {
sendContactForm();
return false;
});
</script>
当我删除此脚本时,表单正在发送,并保存到谷歌,但点击提交后,我重定向到谷歌“谢谢”页面。我不想重定向并显示确认
就像在脚本中一样。如何解决这个问题?
【问题讨论】:
-
您正在将
MY-FORM-KEY更改为您的谷歌密钥,对吧?你得到什么错误?您的表格是否已提交? (在 Google Chrome 上按 F12 并观看 网络 部分)。 -
已提交,但看起来所有输入的值都是空的,但它们不是空的
-
您是否检查了表单中每个
input的正确name="..."以及 Google 表单中的预期名称? -
是的,所有输入的名称和ID都是正确的
-
@rodrigogq 我找到了显示确认提交表单的 javascript。该脚本如下所示: 如果我评论这个脚本,表单被发送,如何修复它?
标签: javascript jquery html google-sheets google-forms