微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用2条条件搜索脚本 Google API和电子表格

如何解决使用2条条件搜索脚本 Google API和电子表格

我有一个包含5个字段的表单,该表单连接到Google Spreadsheet。当我的用户在前2个字段中输入数据时,其他3个字段将根据电子表格的数据进行更新。 我的脚本可以很好地使用一个条件,但是我需要第二个条件才能更新其他3个字段。 我的HTML:

  <!DOCTYPE HTML>
  <HTML>
  <head>
<base target="_top">
<Meta name="viewport" content="width=device-width,initial-scale=1.0"/>    
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
 <?!=include("page-css"); ?>
 </head>
 <body>
 <div class="container">    
    <div class="row">
       <div class="input-field col s12">
         <input id="ds" type="text" class="validate">
         <label for="ds">Contract Number</label>
       </div>          
    </div> 
    <div class="row">
       <div class="input-field col s12">
         <input id="pn" type="text" class="validate">
         <label for="pn">Number</label>
       </div>          
    </div> 
    <h5> RESULTS </h5>
    <div class="row">
    <div class="input-field col s12">
      <input disabled id="est" type="text" class="validate">
      <label for="est" class="active">Validity date from</label>
    </div>
    </div>
    <div class="row">
    <div class="input-field col s12">
      <input disabled id="est1" type="text" class="validate">
      <label for="est1" class="active">Expiry Date</label>
    </div>
    </div>  
    <div class="row">
    <div class="input-field col s12">
      <input disabled id="est2" type="text" class="validate">
      <label for="est2" class="active">Type</label>
    </div>
    </div>       
</div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    <?!=include("page-js"); ?>
  </body>
  </html>

我的脚本必须要做搜索“ ds”和“ pn”的“ est”,“ est1”,“ est2”值

脚本是:

     <script>

  document.addEventListener('DOMContentLoaded',function() {
  var elems = document.querySelectorAll('select');
  var instances = M.FormSelect.init(elems);
   });

   document.getElementById("ds").addEventListener("input",getEstimate)

function getEstimate(){
var contractNumber = document.getElementById("ds").value;
if(contractNumber.length === 8){
google.script.run.withSuccessHandler(upadteEstimate).getDateStart(contractNumber);
google.script.run.withSuccessHandler(upadteEstimate1).getDateExpiry(contractNumber);
google.script.run.withSuccessHandler(upadteEstimate2).getInsurancePlan(contractNumber);
}  
}

function upadteEstimate(DateStart){
document.getElementById("est").value = DateStart;
M.updateTextFields();    

}

function upadteEstimate1(DateExpiry){
document.getElementById("est1").value = DateExpiry;
M.updateTextFields();    

}
 
function upadteEstimate2(InsurancePlan){
document.getElementById("est2").value = InsurancePlan;
M.updateTextFields();    

}   
</script>

我尝试了很多事情,但都没有成功。如果有人可以给我一些提示或建议,它将大有帮助... 谢谢 J

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。