Hi!
I have read countless pages around the net and the ones I can find here, but I still can not get a javascript delete confirm box to work correctly for my site written in PHP. I have tried everything I can find. Here is my scenario:
I am finishing a script which queries the database for exceptions. It then lists various information about that record and offers a delete button to delete it at the end. Here is that code:
[code]
echo ‘<td>’, ‘<a href=”database_check.php?action=delete_products&ref=5&products_id=’.$products_id.'” onclick=”confirmDelete();”>’,'<img src=”includes/languages/english/images/buttons/button_delete.gif” border=”0″ alt=”Click to delete record”></a>’;
As you see, I am passing 3 variables in this url. I should mention that this code is on the same page where the case “delete_products” is.. and all of that works great. The confirmDelete() code refered to above is this:
[code]
<script>
function confirmDelete()
{
var confirmMe= confirm(“Do you really want to Delete??”);
if (confirmMe== true)
{
return true
}
else
{
return false
}
}
</script>
The confirm box comes up alright.. but.. makes no difference if I click yes or no, it still deletes the record.
By the way, this is what is in the delete_products case:
[code]
case ‘delete_products’:
tep_db_query(“delete from testing_products where products_id = ‘” . $HTTP_GET_VARS[‘products_id’] . “‘”);
tep_db_query(“delete from testing_products_description where products_id = ‘” . $HTTP_GET_VARS[‘products_id’] . “‘”);
tep_db_query(“delete from testing_products_to_categories where products_id = ‘” . $HTTP_GET_VARS[‘products_id’] . “‘”);
$action = $ref;
}
break;
That deletes the record chosen and sends the user right back to the case they came from, thereby refreshing the results if they have more deletions to make. But.. in my case… how do i get this from stopping the delete from happening if the user chooses not to? I’m really not good with javascript at all.. but.. very literate in other languages.
Any help would be appreciated,
Iceman