I had a modal form where you are adding a user and after saving it, it would pass the data to the table. I was able to pass the name form. I want to pass the value of the checkbox in the form to the table if it is checked or not.
Modal Form
<div id="addUser" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div>
<label>Full Name</label>
<div>
<input class="form-control" id="fullname" type="text" required/>
</div>
</div>
<div >
<label>Permissions</label>
<div>
<input type="checkbox" id="add" value="Add" data-parsley-multiple="status">
<label>Add</label>
<input type="checkbox" id="edit" value="Edit" data-parsley-multiple="status">
<label>Edit</label>
<input type="checkbox" id="delete" value="Delete" data-parsley-multiple="status">
<label>Delete</label>
</div>
</div>
<div>
<div class="col-12">
<button class="btn" id="saveUser">Add</button>
</div>
</div>
</div>
</div>
</div>
JS
$("#saveUser").click(function () {
t.row.add(['',
'<input class="form-control" type="text" name="fullname[]" value="'+$("#fullname").val()+'" readonly>',
'<input class="form-control" type="checkbox" name="permissions[]" value="'+$("#add").val()+'" data-parsley-multiple="status">',
'<input class="form-control" type="checkbox" name="permissions[]" value="'+$("#edit").val()+'" data-parsley-multiple="status">',
'<input class="form-control" type="checkbox" name="permissions[]" value="'+$("#delete").val()+'" data-parsley-multiple="status">',
]).draw(false);
});
As you notice in my JS code, I am using datatable codes to add a row. I was able to pass the fullname and also the value of the checkbox (e.g. add, delete). However, I want to pass the check value. If it is check/uncheck in the modal, the checked/unchecked value will pass.