javascript – 删除html表单的确认
作者:互联网
我想在表单按钮中添加删除确认
可能的javascript使用?
<script type="text/javascript">
function confirmDelete() {
return confirm("Are you sure you want to delete?");
}
</script>
这目前在我的表单中工作.
<input type="button" onclick="parent.location='<?php echo "delete.php?id=" . $people['id'] ?>'" value='Delete'>
如何将javascript集成到onclick事件中?使用上面的javascript或任何其他可能更好的方式
解决方法:
在javascript中绑定您的事件处理程序.
<input type="button" id="delete" value='Delete' />
document.getElementById('delete').onclick = function () {
if (confirm('Are you sure?')) {
parent.location='<?php echo "delete.php?id=" . $people['id'] ?>';
}
};
标签:javascript,forms,html,confirmation 来源: https://codeday.me/bug/20190715/1469570.html