Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将google脚本值传递到html_Javascript_Html_Google Apps Script - Fatal编程技术网

Javascript 将google脚本值传递到html

Javascript 将google脚本值传递到html,javascript,html,google-apps-script,Javascript,Html,Google Apps Script,我一直在寻找各种其他的解决方案张贴在这里,但他们似乎都不适合我 我正试图将一个变量从我的google脚本(它最初存储在google的PropertiesService中)传递到我的html,因为我想使用以前保存的数据作为文本输入框的值(显示以前保存的数据) 这是我的gs文件(减去不相关的部分): 这是我的html文件(省略了其他不相关的部分): var timeInput=document.getElementById(“时间”); var timehtml=时间; timeInput.va

我一直在寻找各种其他的解决方案张贴在这里,但他们似乎都不适合我

我正试图将一个变量从我的google脚本(它最初存储在google的PropertiesService中)传递到我的html,因为我想使用以前保存的数据作为文本输入框的值(显示以前保存的数据)

这是我的gs文件(减去不相关的部分):

这是我的html文件(省略了其他不相关的部分):




var timeInput=document.getElementById(“时间”); var timehtml=时间; timeInput.value=timehtml; 函数writeFormData(){ google.script.run.processForm(document.forms[0]); }

也许我的整个方法都错了。但我试图做的是将用户选择(可能希望将userProperties更改为documentProperties,以使设置文档特定)存储在Google的PropertiesService中,然后在侧边栏中按下submit按钮时保存这些值。下次打开侧边栏时,应显示这些保存的设置。

您所处的轨道是正确的。因为您已经将变量传递给HtmlTemplate对象,所以剩下的唯一步骤是使用GAS模板引擎来渲染它

.GS文件

...
htmlTemplate.timehtml = time;
...
HTML模板

   <input type="text" name="time" id="time" value="<?!= timehtml ?>">

非常有魅力,非常感谢!你也知道如何使用单选按钮吗?我试着用同样的逻辑,但似乎对我不起作用。(I向两个单选按钮添加value=”“)
...
htmlTemplate.timehtml = time;
...
   <input type="text" name="time" id="time" value="<?!= timehtml ?>">