访问对象是Google App脚本 [英] Accessing object is Google App Script

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

问题描述

实际上,我在创建表单时遵循HtmlService文档(https://developers.google.com/apps-script/html_service)。我注意到有这个部分,它表示在用户提交表单后它将是一个对象,结构将如下所示:

{myFile :<包含文件的Blob>;
aField:<字段中的值> }



我可以知道如何在Google App Script中访问这些对象?

解决方案

在您的服务器代码中:

  function processForm(theForm){
Logger.log(theForm.aField);
Logger.log(theForm.myFile.getName());

$ / code>

在您的HTML中:

 < form id ='myForm'> 
< input name ='myFile'type ='file'>
< input name ='aField'>
< / form>
< script>
google.script.run.processForm(document.getElementById('myForm'));
< / script>


I am actually following the HtmlService documentation (https://developers.google.com/apps-script/html_service) in creating a form. I notice there is this part where it says it will be an object after user submit the form and the structure will be like this:

{ myFile: <a Blob containing the file>; aField: <the value in the field> }

Can I know how can I access to those object in Google App Script?

解决方案

In your server code:

function processForm(theForm) {
  Logger.log(theForm.aField);
  Logger.log(theForm.myFile.getName());
}

In your HTML:

<form id='myForm'>
<input name='myFile' type='file'>
<input name='aField'>
</form>
<script>
google.script.run.processForm(document.getElementById('myForm'));
</script>

这篇关于访问对象是Google App脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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