I have a table where one of your columns is a checkbox, I need to do when the checkboxes are selected click on a "Delete Selected" button where it is possible to retrieve for me all the selected Checkbox values.
This HTML table comes from an Ajax request, where it is mounted in HTML, so it is dynamic.
while ($linha = $result->fetch_assoc())
{
$codigo= utf8_encode($linha["codigo"])." "
$return.= "<td>". "<input type=\"checkbox\" name=\"cb\" value=\"".$codigo."\" > "."</td>";
$return.= "<td>" . utf8_encode($linha["data"]) . "</td>";
$return.= "<td>" . utf8_encode($linha["hora"]) . "</td>";
$return.= "<td>" . utf8_encode($linha["origem"]) . "</td>";
$return.= "<td>" . utf8_encode($linha["destino"]) . "</td>";
}
How can you do this? should I put my table inside one form and send the form to another page? Currently I tried to do this, so I put this table in a form, and clicking the button sends the data to an Exclude.php page
I tried to use the following command to retrieve the value foreach ($ _POST as $ key = > $ value) { echo $ key; // Here was the code value, but only the name of a button appears, leaving "cb" }
So, how do I retrieve the code? is there a better way to do this? I would also like to know if it is possible to send all selected values via Ajax to the server, how can I resolve this?