no output on the est id value

13 views
Skip to first unread message

Jay Anne Otadora

unread,
Nov 17, 2023, 3:04:51 PM11/17/23
to Google Apps Script Community
I have an ID called est that doesn't show the value that should reflect on hmtl.
everytime i put a zip id the est id should reflect the estimate value. 
here is my html code 
        <div class="row">
            <div class="input-field col s4">
            <i class="material-icons prefix">location_searching</i>
            <input  id="zip" type="text" class="validate">
            <label for="zip">Zip Code</label>
         </div>
        <div class="input-field col s4">
            <i class="material-icons prefix">location_searching</i>
            <input disabled id="est" type="text" class="validate">
            <label for="est" class="active">Estimate </label>
        </div>
      </div>
      </div><!--close row-->


Here is my js code:
function getCost(zipCode){
  var ss = SpreadsheetApp.openByUrl(url);
  var ws = ss.getSheetByName("optionV2");
  var data = ws.getRange(1,1,ws.getLastRow(),2).getValues;
//   //searching in the zipcodelist
   var zipCodeList = data.map(function(r){return r[0];});
   var costList = data.map(function(r){return r[1];});

   var position = zipCodeList.indexOf(zipCode);
//   // check if its greater -1
   if(position > -1){
//     //return the item on the same position
          return costList[position];
  }else{
        return 'no Recored';
    }
 

}
 document.getElementById("zip").addEventListener("input", getEstimate);
function getEstimate(){
      var zipCode = document.getElementById("zip").value;
       google.script.run.getCost(zipCode);
     
   


      // if(zipCode.length >= 2){
       google.script.run.withSuccessHandler(updateEstimate).getCost(zipCode);
   
             
      // }
    }
     
    //  //accept whatever the getcost has
     function updateEstimate(cost){
    //show value on estimate label
      document.getElementById("est").value = cost;
       M.updateTextFields();

      }
     

   
....
please help!!!
Reply all
Reply to author
Forward
0 new messages