HtmlService GAS在html表单之间传递变量 [英] HtmlService GAS pass variables between html forms
本文介绍了HtmlService GAS在html表单之间传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了两个HTML页面page1.html
和page2.html
.如何在单击第1页的按钮时将ID从第1页传递到第2页?
I have created two HTML pages page1.html
and page2.html
. How can I pass an ID from page1 to page2 on a button click in page1?
function addAuc(form) {
var s1 = form.ID,
s2 = form.Name,
s3 = form.Email,
html = HtmlService.createTemplateFromFile('page2');
html.setSandboxMode(HtmlService.SandboxMode.NATIVE);
html.setWidth(700);
html.setHeight(600); SpreadsheetApp.getUi().showModelessDialog(html, 'Reg');
return s1;
}
page1.html:
<form id="myForm">
<input type="button" value="Choose" onclick="google.script.run.withSuccessHandler(updateUrl).rowArray()" />
<input onclick="google.script.run.addAuc(document.forms[0])" type="button" value="Add" />
<input type="button" value="Close" onclick="google.script.host.close()" /><br/>
<label id="Name"></label>
</form>
<label id="ID">1</label>|
<label id="Name">Jon</label>|
<label id="Email">jon@email.com</label>|
<label id="Phone">004423554897</label>
page2.html:
<div class="info" >
<span id="ID" name="ID"></span>
</div>
推荐答案
在您的示例中,您会将变量传递给'html'模板对象.
In your example you would pass the variable to the 'html' template object.
html = HtmlService.createTemplateFromFile('page2');
html.id = s1;
然后在第2页中使用标记打印出id值;
Then in page 2 use the the tag to print out the id value;
<div class="info" >
<span id="ID" name="ID"><?=id?></span>
</div>
这篇关于HtmlService GAS在html表单之间传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文