Form inputs not working... what am I doing wrong?
Form inputs not working... what am I doing wrong?
Hi All
I have a input field in my DataTables table.
I have this code to make the table work:
<script>
$(document).ready( function ()
{
var table = $('#tableshoppingcart').DataTable({
"responsive": true,
"autoWidth": true,
"pageLength": 10,
"language": { "emptyTable": "Your cart is currently empty..." },
"columnDefs": [{ "targets": [1] }]
});
} );
</script>
This way the input field information is not passing when I post.
I have tried this:
<script>
$(document).ready( function ()
{
var table = $('#tableshoppingcart').DataTable({
"responsive": true,
"autoWidth": true,
"pageLength": 10,
"language": { "emptyTable": "Your cart is currently empty..." }
});
var table = $('#example').DataTable({
columnDefs: [{
orderable: false,
targets: [1]
}]
} );
</script>
And the input field passes but the DataTables code stops working... I believe this is due to the difference in the table var name... if I change the second one to tableshoppingcart I get a popup error saying I can't declare it twice.
I am not great when it comes to this stuff and I am sure this is simple to fix.
Any help would be great.
mrmbarnes
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
What input field?
What is the code that is performing the post?
How does it stop working?
In your first example you have
"columnDefs": [{ "targets": [1] }]
. You haven't defined what you want to do likeorderable: false,
.My guess is you don't have a second table with the id
example
. So this isn't doing anything.Yes, and if you read the link provided in the pop up it will explain the error.
Unfortunately you haven't provided the code that shows the problem. We will need more information to help. The best would be a link to your page or a test case replicating the issue:
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I cannot add my code?
It is a basic form.
I do not want to change anything... all I need is for the form information to be posted when the form is submitted?
Are you using Editor or ajax to send the Post data?
Without seeing the code you have for the form and to post the data its impossible to say what the problem is. The Datatables initialization code is not enough to knwo what you are doing.
If you are unable to provide a test case then please post your Javascript code. Maybe we can see something. Also if something isn't working as expected then look at the browser's console for errors.
Kevin