This is more of a javaascript problem, but you guys might know a solution anyway, so I'll try :p
I want to build in a javascript confirm to have a user confirm the deletion of a database field. I got this:
<SCRIPT language="JavaScript">
<!--
var delcat = confirm("Do you really want to delete <?php echo $_POST['catname']; ?>?");
if (delcat==true)
{
<?php
$sql = mysql_connect($sqlhost,$sqluser,$sqlpass);
mysql_select_db($sqldb);
mysql_query('DELETE FROM `fb_category` WHERE id=' . $_POST['catid'] . ' LIMIT 1') or die('Unable to delete category, do you have DELETE rights?');
mysql_close($sql);
?>
window.location="categories.php";
}
else
{
window.location="categories.php";
}
//-->
</SCRIPT>
But whatever you choose, it always deletes the field, also when you click Cancel. Any clues ? :bemused: