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

some problem about value of table,thanks #31

Closed axuebin closed 8 years ago

axuebin commented 8 years ago

I put the form in the table, when I use table-to-json, It cannot be displayed, like this:

<table>
    <thead>
        <tr
            <th>id</th>
            <th>text</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td><input type="text"></td>
        </tr>
</table>

Should I do something? Thanks.

axuebin commented 8 years ago

Thanks anyway. I found the solution....

function tableToJson() {
    var table = $('#table1').tableToJSON({
        textExtractor: function (cellIndex, $cell) {
            // get text from an input or select inside table cells;
            // if empty or non-existent, get the cell text
            return $cell.find('input,input').val() || $cell.text();
        }
    }); 
}