- 使用URL
url + ?formid=###
访问Web Apps时,要将###
的值放在文本框中。
- URL类似于
https://script.google.com/macros/s/###/exec?formid=###
。
如果我的理解正确,那么这个答案如何?请认为这只是几个答案之一。
修改点:
- 在此修改中,我使用
google.script.url.getLocation()
来获取查询参数。
修改后的脚本:
请如下修改html.html
。
<!DOCTYPE html>
<html>
<head>
</head>
<style>
</style>
<body>
<form>
<h1><center>Verification</center></h1>
Form ID:<input type="number" name="formid" id="formid" class="formid">
</form>
<script>
google.script.url.getLocation(function(location) {
document.getElementById("formid").value = location.parameters.formid[0];
});
</script>
</body>
</html>
- 通过上述修改,当您使用
https://script.google.com/macros/s/###/exec?formid=12345
访问Web Apps时,12345
将被放置到文本框中。
参考:
如果我误解了您的问题,而这不是您想要的方向,我深表歉意。
,
使用Jquery:
<script>
$(function(){
google.script.run
.withSuccessHandler(function(v){
$('#formid').val(v);
})
.getTheValueOfV();
});
</scrip>
使用常规JavaScript
<script>
window.onload=function(){
google.script.run
.withSuccessHandler(function(v){
document.getElementById('formId').value=v;
})
.getTheValueOfV();
};
</script>
Code.gs:
function getTheValueOfV() {
var ss=SpreadsheetApp.getActive();
return ss.getRangeByName("TheRangeWhereYouFindtheValueofv").getValue();
}
您可以根据需要将脚本放在头部或正文中。如果您使用JQuery,则头部需要这样的内容。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
本文链接:https://www.f2er.com/3141364.html