Javascript 在删除数据库中的行之前需要获得确认框
点击这个链接,我需要一个确认框。如果单击“是”,它将移动到给定的地址;否则,它应保持在同一页中 此代码位于myJavascript 在删除数据库中的行之前需要获得确认框,javascript,php,Javascript,Php,点击这个链接,我需要一个确认框。如果单击“是”,它将移动到给定的地址;否则,它应保持在同一页中 此代码位于myglossaryindex.php中: echo '<td><a href="deleteingredient.php?id=' . mysql_result($result, $i, 'id') . '">Delete</a></td>'; if (isset($_GET['id']) && is_numeric($_G
glossaryindex.php
中:
echo '<td><a href="deleteingredient.php?id=' . mysql_result($result, $i, 'id') . '">Delete</a></td>';
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
// get id value
$id = $_GET['id'];
// delete the entry
$result = mysql_query("DELETE FROM ingredient_details WHERE id=$id")
or die(mysql_error());
// redirect back to the view page
header("Location: glossaryindex.php");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: glossaryindex.php");
}
将其置于
表单中
,然后使用JavaScript确认()
。感谢您的回复,它可以正常工作