How to send checkbox value from sidebar to googlesheet?

17 views Asked by At

I've tried to send checkboxes values from sidebar to googlesheet using appscript. I've built the form, and when I clicked submit button, it sends only the first input i.e. the date, but the second input from checkboxex only results as [Ljava.lang.Object;@14851037. I assummed maybe due to the array of array (I checked the console.log()). I've tried to use filter or flat, but no good results. Maybe any ideas from you? Very much appreciate for the thoughts.

This is the code.gs

function onOpen() {
 SpreadsheetApp
   .getUi()
   .createMenu("Meeting")
   .addItem("Attendance record","absen")
   .addToUi();

}

function absen(){
  var myForm = HtmlService.createHtmlOutputFromFile('Absen').setTitle('Attendance Record');
  SpreadsheetApp.getUi().showSidebar(myForm);
}
function prosesformabsen(input){
  const kumpulanabsen = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Absen");
  const dataabsen = [ input.Tanggal, input.Absen, ];
  console.log(input); // I know the input already contains data.

  kumpulanabsen.appendRow(dataabsen);
  displaytoast("Recorded. Thank you." ," Congratulations! ",15); 


}

function displaytoast(berita,judul,lama){
  SpreadsheetApp.getActiveSpreadsheet().toast(berita,judul,lama);
}

This is the HTML code

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <form id="Formabsen">
      <label for="Tanggal">Meeting date: </label>
        <input id="Tanggal" name="Tanggal" type="date" required />
      <br>
      
      <label for ="Peserta">Staff: </label>
        <br>
        <input type ="checkbox" id= "TIDAK ADA" name = "Absen" value ="NONE"><label for ="Absen">NONE</label><br>
        <input type ="checkbox" id= "Mualim" name = "Absen" value ="Mualim"><label for ="Absen">Mualim</label><br>
        <input type ="checkbox" id= "Elsa" name = "Absen" value ="Elsa"><label for ="Absen">Elsa</label><br>
        <input type ="checkbox" id= "Beni" name = "Absen" value ="Beni"><label for ="Absen">Beni</label><br>
        <input type ="checkbox" id= "Nani" name = "Absen" value ="Nani"><label for ="Absen">Nani</label><br>
        <input type ="checkbox" id= "Eva" name = "Absen" value ="Eva"><label for ="Absen">Eva</label><br>
        
        <br>
        <button class="action" onclick="google.script.run.prosesformabsen(this.parentNode);">Submit</button>
  </form>

  </body>
</html>

Here's the form and the googlesheet: Here's the form and the data sent to Googlesheet

Here's the result from console.log()

Here is the link

I've tried to use filter and flat, but no good results.

0

There are 0 answers