简体   繁体   中英

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

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM