Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <table id="library_info_tbl">
   <thead>
     <th>Call No.</th>
     <th>Book</th>
     <th>Accession No.</th>
     <th>Status</th>
   </thead>
   <tbody>
     <tr><td>12<td><td>ffyuyudf</td><td>61</td><td>Lost</td></tr>    
     <tr><td>12<td><td>ffyuyudf</td><td>62</td><td>Damaged</td></tr>  
     <tr><td>12<td><td>ffyuyudf</td><td>63</td><td>Damaged</td></tr>  
     <tr><td>13<td><td>abcdef</td><td>72</td><td>Lost</td></tr>  
     <tr><td>13<td><td>abcdef</td><td>73</td><td>Lost</td></tr>  
   </tbody>
  </table>
  <script src="https://code.jquery.com/jquery-2.0.3.js"></script>
</body>
</html>
 
var libraryInfos = [];
$("#library_info_tbl tbody tr").each(function(){
  var tds = $("td", this);
  var callNo = tds.first().html();
  if(typeof libraryInfos[callNo] == 'undefined'){
    libraryInfos[callNo] = [];
  }
  
  libraryInfos[callNo].push({
    status: $(tds[4]).html(),
    accessionNo: parseInt($(tds[3]).html())
  });
});
$.each(libraryInfos, function(callNo, statusArr){
  if(statusArr){
    var reqData = { callno: callNo, statusarray: statusArr };
    
    $.ajax({
      url: 'index.php?action=savestatus',
      type: 'POST',
      dataType: 'JSON',
      data: reqData
    });
    
    console.log(reqData);
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
DamianImrichpro
0viewers