简体   繁体   English

在href上的HTML / PHP确认

[英]HTML/PHP Confirmation on href

I have this line of code that executes that runs a delete script for an item with a specific id which is retrieved from the url. 我有这行代码执行,它为从URL检索到的具有特定ID的项目运行删除脚本。

    echo " ( <a href=\"DeleteCategory.php?id="  . $row['id']    .   "\" >Delete</a> )";

How can I add an onclick confirmation that determines if it goes to the link or not. 如何添加onclick确认,以确定是否转到链接。 I would rather not have to use any javascript. 我宁愿不必使用任何JavaScript。

Thanks 谢谢

Add onclick="return confirm ('Are you sure?')" 添加onclick="return confirm ('Are you sure?')"

Hope that helps. 希望能有所帮助。

echo ' ( <a href="DeleteCategory.php?id='.$row['id'].'" onclick="return confirm(\'Are you sure you want delete this catagory?\')">Delete</a> )';

The return value of an event handler determines whether or not the default browser behaviour should take place as well. 事件处理程序的返回值确定默认浏览器行为是否也应发生。 In the case of clicking on links, this would be following the link. 在单击链接的情况下,将在链接之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM