gpt4 book ai didi

javascript - window.location.assign 不继续

转载 作者:行者123 更新时间:2023-11-30 14:47:44 25 4
gpt4 key购买 nike

我正在尝试删除数据库中的一条记录。

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'");

最佳答案

在window.location.assign()之后请加上return false;像这样

window.location.assign("deleteunit.php?val="+unit);
return false;

关于javascript - window.location.assign 不继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48639777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com