0

我创建了一个从我的 google 工作表中提取的表,并为 Web 应用程序(前端)中的每条记录添加了一些复选框。

  1. 从分配的 id 的表数组中获取复选框值的 JS 是什么
  2. 然后根据分配的 id 将此复选框值放置到 google 工作表中。

对不起,我只是一个初学者。先感谢您!

下面供大家参考

-

<!DOCTYPE html> <html>   <head>    <base target="_top">
          <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1">
       </head>    <body>
    
        <br>
        <h1>Survey</h1>
        <br>    <div class="container">
         <div class="col s12">
                <div id="table-body"></div>
         </div>   </div>   <script>
       window.addEventListener("load", functionInit, true); 
    
       //INITIALIZE FUNCTIONS ONLOAD   function functionInit(){  
         getAllData();   };          //CREATE THE DATA TABLE   function createTable(dataArray) {    if(dataArray){
        var result = "<table class='table table-sm' style='font-size:0.8em'>"+
                     "<thead style='white-space: nowrap'>"+
                       "<tr>"+                              
                        "<th scope='col'>id</th>"+
                        "<th scope='col'>name</th>"+
                        "<th scope='col'>Question 1</th>"+
                        "<th scope='col'>Question 2</th>"+
                        "<th scope='col'>Question 3</th>"+
                        "<th scope='col'>Question 4</th>"+
                      "</tr>"+
                    "</thead>";
        for(var i=0; i<dataArray.length; i++) {
            result += "<tr>";
            for(var j=0; j<dataArray[i].length; j++){
                result += "<td>"+dataArray[i][j]+"</td>";
            }
            
            result += "<td><input type='checkbox' name='check' value='check1'/></td>";
            result += "<td><input type='checkbox' name='check' value='check2'/></td>";
            result += "<td><input type='checkbox' name='check' value='check3'/></td>";
            result += "<td><input type='checkbox' name='check' value='check4'/></td>";
           
            result += "</tr>";
        }
        result += "</table>";
        var div = document.getElementById('table-body');
        div.innerHTML = result;
        
        }   }
      
        //GET ALL DATA   function getAllData(){    //document.getElementById('dataTable').innerHTML = "";   
   google.script.run.withSuccessHandler(createTable).getAllData();   }
        </script>
          </body> </html>

下面是谷歌电子表格的图像

在此处输入图像描述

和 Web App 的图像

在此处输入图像描述

4

0 回答 0