我在这附近有新人。我正在App脚本插件中工作,我想知道如何使用侧边栏中复选框的选中值来启动特定的GS功能?
以下是侧边栏的示例HTML:
<!DOCTYPE html>
<html>
<head>
<link href="https://ssl.gstatic.com/docs/script/css/add-ons.css"
rel="stylesheet">
</head>
<body>
<div class="sidebar">
<p>Please select the checkbox you need</p>
<form>
<div class="block form-group">
<div><input type="checkbox" id="CHECKBOX1">
<label for="CHECKBOX1">CHECKBOX1</label></div>
<div><input type="checkbox" id="CHECKBOX2">
<label for="CHECKBOX2">CHECKBOX2</label></div>
<div><input type="checkbox" id="CHECKBOX3">
<label for="CHECKBOX3">CHECKBOX3</label></div>
<div class="block">
<button class="action" id="useGsFunctions">Start Functions</button>
</div>
</form>
</div>
</body>
</html>
现在我想在按下useGsFunctions时调用,如果checkbox1为真,则调用GS function1;如果选择了checkbox2,则调用GS函数2。但是你怎么做到的?
提前感谢您的帮助和耐心。
答案 0 :(得分:1)
这可能会对你有帮助,
<!DOCTYPE html>
<html>
<head>
<link href="https://ssl.gstatic.com/docs/script/css/add-ons.css"
rel="stylesheet">
<script>
function check(){
if(document.getElementById("CHECKBOX1").checked){
//Call your GS function 1
}
else if(document.getElementById("CHECKBOX2").checked){
//Call your GS function 2
}
else if(document.getElementById("CHECKBOX3").checked){
//Call your GS function 3
}
}
</script>
</head>
<body>
<div class="sidebar">
<p>Please select the checkbox you need</p>
<form>
<div class="block form-group">
<div><input type="checkbox" id="CHECKBOX1">
<label for="CHECKBOX1">CHECKBOX1</label></div>
<div><input type="checkbox" id="CHECKBOX2">
<label for="CHECKBOX2">CHECKBOX2</label></div>
<div><input type="checkbox" id="CHECKBOX3">
<label for="CHECKBOX3">CHECKBOX3</label></div>
<div class="block">
<button type = "button" class="action" id="useGsFunctions" onclick="check()">Start Functions</button>
</div>
</form>
</div>
</body>
</html>