gpt4 book ai didi

javascript - 调用函数时下拉菜单选项消失

转载 作者:行者123 更新时间:2023-11-28 06:35:43 25 4
gpt4 key购买 nike

我正在尝试将下拉菜单选择传递给我的 Javascript 文件中的函数。这是可行的,但是一旦我点击提交按钮,下拉菜单选项就会被删除,并且我留下一个空的下拉菜单。 (这似乎只有当它是谷歌脚本中的应用程序时才会发生。)

有什么想法为什么会发生这种情况吗?有没有更好的方法来使用应用程序脚本来做到这一点?

任何帮助将不胜感激。

function doSomething(){
var x = document.getElementById("API_key").value;
document.getElementById("API_key").innerHTML = x;

var subdomain =document.getElementById("subdomain").value;
document.getElementById("subdomain").innerHTML = subdomain;

var state = document.getElementById("stateSelect").value;
document.getElementById("stateSelect").innerHTML = state;

google.script.run.getInfo(x,subdomain,state);

}
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<head>
<base target="_top">
</head>
<body>

<P ALIGN=Center>

<BLOCKQUOTE>


<P ALIGN=Left>
<div class="inline form-group">
<label for="API_key">API Key</label>
<input type="text" id="API_key" style="width: 150px;" value="Enter API key here!">
</div>


<P ALIGN=Left>
<div class="inline form-group">
<p>
<label for="Subdomain">Subdomain</label>
<input type="text" id="subdomain" style="width: 150px;">
</p>
</div>

<select id ="stateSelect">
<option value="">All</option>
<option value="&state=active">Active</option>
<option value="&state=past_due">Past Due</option>
<option value="&state=canceled">Canceled</option>
<option value="&state=expired">Expired</option>
<option value="&state=trialing">Trialing</option>
</select>

<div>
<input type="checkbox" id="Product Info" checked>
<label for="Product Info">Product Info</label>
</div>

<div>
<input type="checkbox" id="Shipping Info">
<label for="Shipping Info">Shipping Info</label>
</div>


<div>
<p>
<input class="action" type="button" onclick="doSomething()" value="Get Info!" />
</p>
</div>
</BLOCKQUOTE>
</body>
</html>

最佳答案

function doSomething(){
var x = document.getElementById("API_key").value;


var subdomain =document.getElementById("subdomain").value;


var state = document.getElementById("stateSelect").value;



google.script.run.getInfo(x,subdomain,state);

}
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<head>
<base target="_top">
</head>
<body>

<P ALIGN=Center>

<BLOCKQUOTE>


<P ALIGN=Left>
<div class="inline form-group">
<label for="API_key">API Key</label>
<input type="text" id="API_key" style="width: 150px;" value="Enter API key here!">

</div>


<P ALIGN=Left>
<div class="inline form-group">
<p>
<label for="Subdomain">Subdomain</label>
<input type="text" id="subdomain" style="width: 150px;">

</p>
</div>

<select id ="stateSelect">
<option value="">All</option>
<option value="&state=active">Active</option>
<option value="&state=past_due">Past Due</option>
<option value="&state=canceled">Canceled</option>
<option value="&state=expired">Expired</option>
<option value="&state=trialing">Trialing</option>
</select>


<div>
<input type="checkbox" id="Product Info" checked>
<label for="Product Info">Product Info</label>
</div>

<div>
<input type="checkbox" id="Shipping Info">
<label for="Shipping Info">Shipping Info</label>
</div>


<div>
<p>
<input class="action" type="button" onclick="doSomething()" value="Get Info!" />
</p>
</div>
</BLOCKQUOTE>
</body>
</html>

关于javascript - 调用函数时下拉菜单选项消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34308506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com