我正在尝试删除数据库中的记录。
HTML
<a href="" onclick="return delUnit('grams');">DELETE</a>
JS
function delUnit(unit)
{
var r=window.confirm("Are you sure you want to delete this unit?");
if (r==true)
{
//window.alert(val); I used alert to see if val was containing the word grams
window.location.assign("deleteunit.php?val="+unit);
return false;
}
}
PHP
$val = $_GET['val'];
mysql_query("DELETE FROM setuptb WHERE val='$val' AND category='UNIT'");
答案 0 :(得分:2)
在window.location.assign()之后请添加return false; 像这样
window.location.assign("deleteunit.php?val="+unit);
return false;