How can I submit my Selected Row's Data via Button click?

How can I submit my Selected Row's Data via Button click?

r00flr00flr00flr00fl Posts: 3Questions: 1Answers: 0

I'm using a function that lets me select multiple rows in my Table:

<script>
$(document).ready(function() {
    $('#example').DataTable( {
    "iDisplayLength": 30,
    "order": [[ 6, "desc" ]],
  } );
  
    $('#example tbody').on( 'click', 'tr', function () {
        $(this).toggleClass('selected');
    } );
} );
</script>

In addition my table is inside a form-tag that also has a button included, which should submit the data of my selected rows on click.

<form role="form" action="" method="GET">
    <table id="example" class="display compact cell-border" width="100%" cellspacing="0">
        <thead>
            <tr>
                <th>Testcase ID</th>
                <th>OrderNr</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Testcase ID</th>
                <th>OrderNr</th>
            </tr>
        </tfoot>
        <tbody>
            <tr>
                <td>Some Text 123</td>
                <td>Some Text 456</td>
            </tr>
            <tr>
                <td>Some Text 678</td>
                <td>Some Text 951</td>
            </tr>
        </tbody>
    </table>
    <button type="submit" id="button" class="btn btn-default btn-success pull-right">Create</button>
</form>

How can I post the selected row's data when clicking the button?

Answers

  • r00flr00flr00flr00fl Posts: 3Questions: 1Answers: 0

    I figured out that I probably need something like:

        var table = $('#example').DataTable();
        $('#button').click( function () {
            table.rows('.selected').data() <!-- how to submit this data on button click? -->
        } );
    

    but I'm not sure how to submit this data on button click

  • r00flr00flr00flr00fl Posts: 3Questions: 1Answers: 0

    anyone? :(

  • crastucrastu Posts: 1Questions: 0Answers: 0

    It's my problem to

This discussion has been closed.