简体   繁体   English

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

[英]Dropdown menu choices disappear when function is called

I'm trying to pass in the dropdown menu selection to a function in my Javascript File. 我正在尝试将下拉菜单选择传递给Javascript文件中的函数。 This works, but as soon as I hit the submit button the dropdown menu choices get deleted, and I'm left with an empty dropdown menu. 这可行,但是当我按下“提交”按钮时,下拉菜单选项就会被删除,而我留下的是空的下拉菜单。 (This seems to only happen when it's an app in google scripts.) (这似乎只有在它是Google脚本中的应用程序时才会发生。)

Any thoughts why this is happening? 有什么想法为什么会这样? Is there a better way to do this with apps script? 有没有更好的方法可以通过应用脚本执行此操作?

Any help would be greatly appreciated. 任何帮助将不胜感激。

 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> 

This is not necessary .just comment and check it 这不是必需的。只需评论并检查

 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