我的jQuery DataTable复选框不起作用,我做错了什么?

时间:2013-02-18 13:52:19

标签: jquery jquery-datatables

我正在尝试实现复选框以提交表单但我意识到它不会以这种方式工作。实现这个的正确方法是什么?我在这里读了一些例子,但无法理解。

<form method="post" name="search_form" action="<?php echo $linksearch; ?>">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="search_table">
<thead>
<tr>
<th>Process1</th>
<th>Process2</th>
<th>Process3</th>
<th>Process4</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$sql = "select * from activity_temp";
$result=tep_db_query($sql);
$sc=0;
while($row = mysql_fetch_array($result)){
   echo "<tr>";
   echo "<td>".$row['p1']."</td>";
   echo "<td>".$row['p2']."</td>";
   echo "<td>".$row['p3']."</td>";
   echo "<td>".$row['p4']."</td>";
   echo "<td class=\"center\"><input type=\"checkbox\" name=\"search_cb[".$row['temp_id']."]\" value=\"on\"></td>";
   echo "</tr>";
$sc++;
}
?>
</tbody>
<tfoot>
<tr><td colspan="5" align="right">
<input id="search_form_submit" type="submit" name="submit" value="Search" class="submit" />
</td></tr>
</tfoot>
</table>
</form>

我这样做吗?

$('#search_table').dataTable({
    "aoColumnDefs": [{
       "bSortable": false, "aTargets": [4]
    }],
   "aoColumns": [
    { "mDataProp": "checkBox" }],
           "aaData": [{
        "checkBox": "<input type="checkbox" name="search_cb" value="on" />"
    }]         
});

1 个答案:

答案 0 :(得分:1)

$('#form').submit( function() {
    var sData = $('input', oTable.fnGetNodes()).serialize();
    alert( "The following data would have been submitted to the server: \n\n"+sData );
    return false;
} );

来源:http://datatables.net/examples/api/form.html