Javascript 如何从GoogleSheet中的元素更新表单?
我有一个自定义的HTML表单在我的谷歌表Javascript 如何从GoogleSheet中的元素更新表单?,javascript,html,google-apps-script,google-sheets,Javascript,Html,Google Apps Script,Google Sheets,我有一个自定义的HTML表单在我的谷歌表 一行 Статья Дата транзакции Описание Сумма (руб.) Добавить, как новую запись Подтвердить document.querySelector(“myform”).addEventListener(“提交”, 职能(e) { e、 preventDefault();//停止表单提交 console.log(这个) google.script.run.withSuccessHa
一行
Статья
Дата транзакции
Описание
Сумма (руб.)
Добавить, как новую запись
Подтвердить
document.querySelector(“myform”).addEventListener(“提交”,
职能(e)
{
e、 preventDefault();//停止表单提交
console.log(这个)
google.script.run.withSuccessHandler(()=>google.script.host.close()).addNewItem(此);
}
);
据我所知,您希望将电子表格中的值输入表单
在这种情况下,可以通过将键添加到模板对象,将值从后端传递到前端。请参见下面的示例:
// A template which evaluates to whatever is bound to 'foo'.
var template = HtmlService.createTemplate('<?= foo ?>');
template.foo = 'Hello World!';
Logger.log(template.evaluate().getContent()); // will log 'Hello World!'
//计算为绑定到“foo”的任何内容的模板。
var template=HtmlService.createTemplate(“”);
template.foo='Hello World!';
Logger.log(template.evaluate().getContent());//将记录“你好,世界!”
因此,在前端,只需将值添加到输入中,如下所示:
<input type="text" value="<?= foo ?>">
谢谢。但它不适用于日期类型。如何修复它?将日期解析为字符串,例如使用:var someDate=new date()输出yyyy mm dd;var niceDate=someDate.toISOString().substring(0,10);