hope everyone is enjoying their day coding so far :D. i'm relatively new to JQUERY and AJAX been trying to find my way around, i'm getting there though. I have one minor problem however. I have HTML content that was generated from a MYSQL database using PHP (so the values for the checkboxes vary); it's a simple internal messaging program that i am working on for my website. I have a single check box that i can click that will select all the other checkboxes on the page. However what i hope to achieve is when ever the user selects a specific amount of check boxes or even a few, then presses a picture it with then call on my php file which will be responsible for deleting the message which the user checked. This previous question helped alot: How to pass jQuery variables to PHP variable? but i have numerous check boxes
HTML/JS:
<body>
Check Box: <input type="checkbox" name="check" value="1">
Check Box: <input type="checkbox" name="check" value="4">
Check Box: <input type="checkbox" name="check" value="3">
Check Box: <input type="checkbox" name="check" value="4">
<img id = "delete" src="http://icons.iconarchive.com/icons/visualpharm/must-have/256/Delete-icon.png">
<script>
$("#delete").click(function () {
$.post('sql_delete.php', 'num=' + $(this).val(), function (response) {
alert(response);
});
});
</script>
</body>
PHP
<?php
require 'functions/init.php';
$messageid = "_$POST[num]";
$sql_statement = "DELETE FROM chj_messages WHERE message_ID = $messageid";
mysql_query($sql_statement);
?>
I suspect that i might need loops in both the JS and PHP not entirely sure though. All your beautiful suggestions are welcomed :D