0

I want to refresh the div tag or the table when i click the button. Just refresh it so that the record will update on the screen. I have no idea on how i ganna code it. I searched but i dont get those codes.

html

<html>
  <head>
    <base target="_top">
    <script>
    </script>
  </head>
  <body>
    <div  id="tables">
      <? var data = getData();?>
      <table id="tableShift1">
      <caption>Shift1</caption>
          <th>   ID   </th>
          <th>   Ldap   </th>
          <th>   Action   </th>
        <? for (var dataList = 1; dataList < data.length; dataList++) {
             if (data[dataList][2] == '') {?>
          <tr >
            <td><?= data[dataList][0] ?></td>
            <td><?= data[dataList][1] ?></td>
            <td><button onclick='google.script.run.setApproved("<?=data[dataList][0]?>")' id='btnLdap'>Approve</button></td>
          </tr>
        <? }  
          } ?>
        </table>
    </div>
  </body>
 <script>

</script>
</html>
shilovk
  • 11,718
  • 17
  • 75
  • 74
MOO
  • 183
  • 2
  • 2
  • 10
  • What do you mean? You want to just reload the page? – Thomas van Oorschot Feb 08 '18 at 07:58
  • Nope. Just the tag ¨tables¨. Because when click the button, its not refreshing like, the data/record I choose should not who on the table. – MOO Feb 08 '18 at 08:01
  • You can use Ajax for this. Someone explains it here: https://stackoverflow.com/questions/17886578/refresh-part-of-page-div – Thomas van Oorschot Feb 08 '18 at 08:14
  • is it posible to do it in `google-app-script`? i tried to do `$(document).ready(function(){ $("button").click(function(){ $("#tables").load("script.google.com/macros/s/AKfycbwoGn41J6koZT17k2QV0LzEIMyWYq8w3Qx2K1Mnbab2/dev"); }); });` but not working. – MOO Feb 08 '18 at 08:21
  • Why do you want to do it with `google-app-script` ? – Thomas van Oorschot Feb 08 '18 at 08:30
  • because my own project is at the `google-app-script`. so i must apply it in google-app-script. – MOO Feb 08 '18 at 08:33
  • Sorry i cant really help you further then ajax but maybe look here: [link](https://developers.google.com/apps-script/guides/html/communication) – Thomas van Oorschot Feb 08 '18 at 08:47
  • Take a look at this example. It shows you how to communicate from javascript to apps script and back again. – Cooper Feb 08 '18 at 16:16

0 Answers0