簡體   English   中英

調用函數時,下拉菜單選項消失

[英]Dropdown menu choices disappear when function is called

我正在嘗試將下拉菜單選擇傳遞給Javascript文件中的函數。 這可行,但是當我按下“提交”按鈕時,下拉菜單選項就會被刪除,而我留下的是空的下拉菜單。 (這似乎只有在它是Google腳本中的應用程序時才會發生。)

有什么想法為什么會這樣? 有沒有更好的方法可以通過應用腳本執行此操作?

任何幫助將不勝感激。

 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> 

這不是必需的。只需評論並檢查

 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);

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM