【问题标题】:Submit a Form using Google App Script's HtmlService使用 Google App Script 的 HtmlService 提交表单
【发布时间】:2012-08-08 05:57:03
【问题描述】:

我在使用 HtmlService 创建的 html 表单中调用服务器端 GAS 函数时遇到问题。 HtmlService 文档说以下应该可以工作:

<form id='myForm'>
  <input name='myFile' type='file'>
  <input name='aField'>

  <input type='button' onclick='google.script.run.processForm(this.parentNode)'>
</form>

我正在使用类似的东西:

<form id='approveForm'>
  <b>Enter Notes about this Approval : </b>
  <br /><br />
  <textarea id = 'approvalNotes' rows='10' cols='135'>Enter notes on this approval for future reference...</textarea>
  <br /><br />
  <b>Request Approved?</b>
  <br /><br />
  <input name = "decision" type="radio" id = 'rApproval' value='Yes'/>Yes<br />
  <input name = "decision" type="radio" id = 'rApproval' value ='No'/>No<br />
  <input name = "decision" type= "radio" id = 'rApproval' value='Pending'/>Pending<br />
  <br /><br />
  <b>Set the Group/List Type : </b>
  <br /><br />
  <input name = "gltype" type="radio" id = 'glType' value='Group'/>Group<br />
  <input name = "gltype" type="radio" id = 'glType' value='List'/>List<br />
  <input name = "gltype" type="radio" id = 'glType' value='?'/>?<br />
  <br />
  <input type='button' value='submit' onclick='google.script.run.processForm(this.parentNode)'>
</form>

虽然我已经做了几乎与文档所说的用于表单提交相同的事情,但我的服务器端函数并没有被调用。有人可以告诉我可能做错了什么以及如何解决这个问题。

【问题讨论】:

  • 我刚刚测试了你的代码,它运行良好。只有您可能想给 textarea 输入一个名称,以便您可以解析它。尝试添加 Logger.log(JSON.stringify(form));在您的 processForm 函数中验证表单是否已传递并且该函数是否真正被调用。

标签: google-apps-script


【解决方案1】:

目前此问题正在here 进行跟踪,HtmlService 中的表单存在问题。 “how to get value entered in UI created with the new HtmlService”提供了一种解决方法,但如果您要处理文件,它就不能很好地工作,因为它只适用于文本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多