lightswitch05 / table-to-json

Serializes HTML tables into JSON objects.
http://lightswitch05.github.io/table-to-json/
MIT License
756 stars 172 forks source link

Dropdown in TD not giving right value. #35

Closed aswa12 closed 7 years ago

aswa12 commented 7 years ago

Hi,

I'm not able to get the proper value of dropdown that I added to one of the td. Heres the fiddle: http://jsfiddle.net/sreedevi/qbuwd3k7/

<table id='example-table' class="table table-striped">
  <thead>
    <tr hidden>
      <th>First Name</th>
      <th>Last Name</th>
      <th data-override="Score">Points</th>
      <th>aggr</th></tr>
  </thead>
  <tbody>
    <tr>
      <td>Jill</td>
      <td>Smith</td>
      <td data-override="disqualified">50</td>
      <td><select type="text" class="gf-form-input" style="width:110px;">
                                                        <option value="avg">AVG</option>
                            <option value="count">COUNT</option></select></td></tr>
</table>

JSON output:

[{"First Name":"Jill","Last Name":"Smith","Score":"disqualified","aggr":"AVG\n COUNT"}]

Please help.

Thanks Sree

aswa12 commented 7 years ago

Sorry that I posted the question before doing a research. Found the answer:

                  textExtractor : {
                        3: function(cellIndex, $cell) {
                          return $cell.find('option:selected').text();
                        }
                      }

Thanks for the plugin.