【问题标题】:HTML input field to Google SpreadsheetGoogle 电子表格的 HTML 输入字段
【发布时间】:2015-03-07 11:47:42
【问题描述】:

似乎我几乎可以使用它,但由于某种原因,当我尝试将输入字段中的数据提交到 Google 电子表格时,它确实添加了数据,但没有添加正在输入的数据。因此,在 Google 电子表格中,我看到了一个带有时间戳的新条目,但没有看到输入的数据。

代码如下:

<script>
$('#emailForm').one('submit',function(){
    var inputField = encodeURIComponent($('#emailForm').val());
var baseURL = 'http://docs.google.com/forms/d/1vl7imylKoya3y8bnboD7WTQ5VsdVw1YmDA1-3_66Apo/formResponse?entry.1017875735=';
var submitRef = '&submit=Submit';
var submitURL = (baseURL + emailAddress + submitRef);
$(this)[0].action=submitURL;
$('#email').addClass('active').val('Thank You!');
setTimeout(function(){
  $('#form-container').hide();
  $('#update-form').animate({'width': '0px'},300,function(){
    $('#get-updates-link').hide();
      $('#email').addClass('active').val('Thank You!');
  });
},1000); 
</script>



<form action="https://docs.google.com/forms/d/1vl7imylKoya3y8bnboD7WTQ5VsdVw1YmDA1-3_66Apo/formResponse?entry.1017875735="

<form id="emailForm" action="" method="POST" target="no-target">
  <input id="email" type="email" placeholder="enter email" name="email">
  <button id="email-submit" type="submit"></button>
</form> 

【问题讨论】:

  • 这个问题有点傻,但是你在哪里使用'inputField'变量?据我了解,此变量包含输入字段的值,但不会发送到电子表格...
  • 这行好像应该是var emailAddress = encodeURIComponent($("#email").val());
  • FWIW:这是我用来测试代码的a fiddle。不幸的是,JSFiddle 不能很好地处理表单。我无法阻止默认提交操作,但我可以使用 keyup 事件来查看数据是否在正确的位置。

标签: javascript jquery html forms google-sheets


【解决方案1】:

您已经定义了 var inputField,但在稍后提交期间,您在 submitURL 代码行中使用了 emailAddress

【讨论】:

    猜你喜欢
    • 2023-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 2018-07-31
    • 2012-08-12
    相关资源
    最近更新 更多