checkbox from database onchange submit form
checkbox from database onchange submit form
In PHP i'm using :
$columns = array(
array( 'db' => 'id', 'dt' => 'id' ),
array( 'db' => 'name', 'dt' => 'name' ),
array( 'db' => 'address', 'dt' => 'address' ),
array( 'db' => 'lat', 'dt' => 'lat' ),
array( 'db' => 'lng', 'dt' => 'lng' ),
array( 'db' => 'type', 'dt' => 'type' ),
array( 'db' => 'fotoA', 'dt' => 'fotoA' ),
array( 'db' => 'fotoB', 'dt' => 'fotoB' ),
array( 'db' => 'fotoC', 'dt' => 'fotoC' ),
array( 'db' => 'faceb', 'dt' => 'faceb' ),
array( 'db' => 'youtu', 'dt' => 'youtu' ),
array( 'db' => 'webs', 'dt' => 'webs' )
);
.
.
.
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
At the clientside:
$(document).ready(function() {
$('#example').DataTable( {
"language": {"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Dutch.json" },
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
"scrollY": 200,
"scrollCollapse": true,
"paging": true,
"columns": [
{ "render": function (data, type, full, meta){
return '<input type="checkbox" name= id[] value="'
+ $('<div/>').text(data).html() + '">';
}
},
{ "data": "name" },
.
.
.
The render function doesn't work, because the sended data is not correct (?)
What I want:
Members can select max.25 other members as friend.
With every change of a checkbox I want to submit a form to load the ID (name of the checkbox) to a table 'friends' in the database.
The ID of the member who's looking for friends is known.
In a second datatable are all the friends selected.
I tried several options.
But I can't get the code correct for the checkbox.
So I can't test the other functions.
Someone who can help?
Answers
I'm on my way....
http://pctraverse.nl/DataTables-1.10.11/examples/server_side/simpleZ.html