我创建了两个HTML网页page1.html
和page2.html
。如何在第1页的按钮单击中将ID从第1页传递到第2页?
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;
}
<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>
<div class="info" >
<span id="ID" name="ID"></span>
</div>
答案 0 :(得分:1)
在您的示例中,您将变量传递给'html'模板对象。
html = HtmlService.createTemplateFromFile('page2');
html.id = s1;
然后在第2页中使用标签打印出id值;
<div class="info" >
<span id="ID" name="ID"><?=id?></span>
</div>