title: How to get data from html table to function using google app script
body: <p>I facing the problem on how i ganna code this. I tried to do <code>google.script.run</code> but not working. When i click the button Approved, the button will throw data to the function. I dont know what to do next. I have no more idea how it works. Thanks!</p>
  
  <p><strong>Index.html</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;div  id="tables"&gt;
        &lt;? var data = getData();?&gt;
        &lt;table id="tableShift1"&gt;
        &lt;caption &gt;Shift1&lt;/caption&gt;
            &lt;th&gt;   ID   &lt;/th&gt;
            &lt;th&gt;   Ldap   &lt;/th&gt;
            &lt;th&gt;   Action   &lt;/th&gt;
          &lt;? for (var dataList = 1; dataList &lt; data.length; dataList++) {
               ?&gt;
            &lt;tr &gt;
              &lt;td&gt;&lt;?= data[dataList][0] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?= data[dataList][1] ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;button onclick='google.script.run.setApproved(data[dataList][0])' id='btnLdap'&gt;Approve&lt;/button&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;?   
            } ?&gt;
          &lt;/table&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p><strong>Code.gs</strong></p>
  
  <pre><code>function setApproved(data) {
    var ss = SpreadsheetApp.openById('17lKIhONfEeNogsBhKtGr4zVaLgH0_199-3J3-0tAdcE');
    var sheet = ss.getActiveSheet();
    var dataRange = sheet.getDataRange();
    var values = dataRange.getValues();
  
   var headers = values[0];
   var ldapIndex = headers.indexOf('ID'); 
   var statusIndex = headers.indexOf('approvalstatus');
  
   var sheetRow;
  
   for( var i = 1 ; i &lt; values.length; i++ )
   {
     var row = values[i];
     if(row[ldapIndex] == data)
     { 
       sheetRow = i +1;
       break;
     }
  }
   ++statusIndex;
   sheet.getRange(sheetRow, statusIndex).setValue('Approved');
  }
  </code></pre>