I have a list of categories paired with checkboxes. I can't find any documentation on how to store all the selected checkboxes in a var and send the data to the server. I need to delete from the database the selected categories. This is part of the code I'm working on.
var cat_id = $('check_box').attr("id"); //gets the id of the checked category
var dataString = 'cat_id=' + cat_id; //should send all the selected checkbox IDs
$('.delete').click(function()
{
$.ajax({
type: "POST",
url: "edit_categories.php",
data: dataString,
cache: false,
success: function(html)
{
window.location.reload(true);
}
});//end ajax
});//end click function
The checkboxes are created dynamically using:
<input type="checkbox" name="check_box" class="check_box"
id="<?php echo $cat_id; ?>" />
Each checkbox will have a unique id and how many they are varies.
In the edit_categories.php I just have an mysql for deleting the categories where cat_id = $_POST['cat_id'] but I can't figure out how to get all the IDs from the selected checkboxes.