I create rows in a HTML table dynamically from MySQL values in a PHP loop. Each row represents a row in MySQL and are identified by an id.
I want to be able to have a <input type='checkbox'> on each row and have a “Delete selected rows” button at the bottom row.
My question is how I should POST the selected checkboxes and how to identify them in the PHP– file.
I have this script to serialize <input type='text'> fields:
function serealizeInputs (input)
{
var array = [];
input.each(function(){ array.push($(this).val()) });
return array;
}
var value = serealizeInputs($('.my_input_field'));
How can I write a similar for checkboxes?
I’m quite new to this as you might see. Let me know if you need to see some more code.
You can use prop attribute to check whether checkbox is checked or not. Here is a live demo