Getting drop-down select value for each row

Hello ,

Having some problem reading data from each row from this table.


I’m trying to replace the first column from input to select dropdown but having trouble figuring out how to read the data for each cell.

It was working fine with an input and normal td but now the select entered the picture and it’s skipping one column.

The day drop-downs are for newly added rows currently.

This is how I’m trying to read the data

$ () {
  var $rows = $TABLE.find('tr:not(:hidden)');
  var $tds = $TABLE.find('td:not(:hidden)');
  var headers = [];
  var data = [];

  // Get the headers (add special header logic here)
  $($rows.shift()).find('th:not(:empty)').each(function () {

  // Turn all existing rows into a loopable array

  $rows.each(function () {
    var $td = $(this).find('td');
    var $td2 = $td.find('input'); 
    var $td3 = $td.find('select');
    var h2 = {};  
    // Use the headers from earlier to name our hash keys
    headers.forEach(function (header, i) {
    // h2[header] = $td.eq(i).text();  

      //the dropdown value -> 
      h2[header] = $td3.eq(i).val();
      if ($td3.eq(i).val() === undefined){ // it's not dropdown ? read it normaly.. 
        h2[header] = ($td.eq(i).text() == '') ? $td2.eq(i).val() : $td.eq(i).text();


  // Output the result

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.