Json 批量表格/表单数据的处理

表格


<html>
<head>

head>
<body>

<table class="table" id="playlistTable">

   <thead>
      <tr>
         <th>名称th>
         <th>城市th>
      tr>
   thead>
   <tbody>
      <tr>
         <td>小明td>
         <td>高密td>
      tr>
      <tr>
         <td>小张td>
         <td>青岛td>
      tr>
   tbody>
table>

 <script>
     var JsonData =  {  a:"", b:""}
     var aa=[];

     var rows = document.getElementById("playlistTable").rows.length; //获得行数(包括thead)

     var colums = document.getElementById("playlistTable").rows[0].cells.length; //获得列数
     for (var i = 1; i < rows; i++) {

         var JsonData = new Object(); 
         JsonData.a = document.getElementById("playlistTable").rows[i].cells[0].innerHTML;

         JsonData.b = document.getElementById("playlistTable").rows[i].cells[1].innerHTML;

         aa.push(JsonData); 
     }

     var obj=JSON.stringify(aa);
     console.log(obj);

 script
body>
html>

表单

http://bbs.csdn.net/topics/390905678
http://blog.csdn.net/nextstand/article/details/50395127

你可能感兴趣的:(WEB前端开发学习笔记,JavaWeb开发学习笔记)