使用Google App脚本的HtmlService提交表单 [英] Submit a Form using Google App Script's HtmlService

查看:107
本文介绍了使用Google App脚本的HtmlService提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用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>
< br />< br />
< textarea id ='approvalNotes'rows = '10'cols ='135'>输入有关此批准的备注供将来参考...< / textarea>
< br />< br />
< b>请求已批准?< / b>
< br />< br />
< input name =decisiontype =radioid ='rApproval'value ='Yes'/> Yes< br />
< input name =decisiontype =radioid ='rApproval'value ='No'/> No< br />
< input name =decisiontype =radioid ='rApproval'value ='Pending'/> Pending< br />>
< br />< br />
设置组/列表类型:< / b>
< br />< br />
< input name =gltypetype =radioid ='glType'value ='Group'/> Group< br />
< input name =gltypetype =radioid ='glType'value ='List'/> List< br />
< input name =gltypetype =radioid ='glType'value ='?'/>?< br />
< br />
< input type ='button'value ='submit'onclick ='google.script.run.processForm(this.parentNode)'>
< / form>

尽管我已经完成了几乎相同的事情,文档说可以用于表单提交,但我的服务器边功能不会被调用。有人可以告诉我可能做错了什么,以及我可能如何解决这个问题。

解决方案

目前这个问题正在追踪在这里,HtmlService中的表单存在一些问题。有一个解决方法提供在如何获得在使用新的HtmlService创建的UI中输入的值,但如果您打算使用文件,因为它只能与文本兼容,所以它不会很好。


I am having issues calling the server side GAS function on form submission in a html form that was created using HtmlService. The HtmlService documentation says that the following should work:

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

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

I'm using something similar:

<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>

And though I have done almost the same thing that the documentation says will work for form submissions, my server side function doesn't get called. Can someone tell what I may be doing wrong and how I may be able to fix this.

解决方案

Currently this issue is being track at here, the form in HtmlService is having some problem. There is a workaround provided at "how to get value entered in UI created with the new HtmlService" but it does not work well if you are going to do with files as it only works with text.

这篇关于使用Google App脚本的HtmlService提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆