我正在使用带有确认对话框的onClick事件创建一个简单的删除链接.我想确认用户想要删除条目.但是,似乎在对话框中单击"取消"时,默认操作(即href链接)仍在进行,因此该条目仍会被删除.不确定我在这里做错了什么......任何输入都会非常感激.
编辑:实际上,代码现在的方式,页面甚至没有进行函数调用...所以,根本没有对话框出现.我确实有onClick代码:
onClick="confirm('Delete entry?')"
Run Code Online (Sandbox Code Playgroud)
这确实带来了一个对话框,但仍然是取消取消的链接.
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<script type="text/javascript">
function delete() {
return confirm('Delete entry?')
}
</script>
...
<tr>
<c:if test="${userIDRO}">
<td>
<a href="showSkill.htm?row=<c:out value="${skill.employeeSkillId}"/>" />
<img src="images/edit.GIF" ALT="Edit this skill." border="1"/></a>
</td>
<td>
<a href="showSkill.htm?row=<c:out value="${skill.employeeSkillId}&remove=1"/>" onClick="return delete()"/>
<img src="images/remove.GIF" ALT="Remove this skill." border="1"/></a>
</td>
</c:if>
</tr>
Run Code Online (Sandbox Code Playgroud)
我需要向网格添加确认删除操作.问题是呈现"删除"链接的方式.我的网格是用vb.net中的代码构建的.我有这个
colDelete.AllowDelete = True
colDelete.Width = "100"
AddHandler CType(gridSavedForLater, Grid).DeleteCommand, AddressOf dgDeleteSelectedIncident
Run Code Online (Sandbox Code Playgroud)
子是以下
Sub dgDeleteSelectedIncident(ByVal sender As Object, ByVal e As GridRecordEventArgs)
Dim message As String = "Are you sure you want to delete this incident?"
Dim caption As String = "Confirm Delete"
Dim result = System.Windows.Forms.MessageBox.Show(message, caption, Windows.Forms.MessageBoxButtons.OKCancel, Windows.Forms.MessageBoxIcon.Warning)
'If (result = Windows.Forms.DialogResult.Cancel) Then
'Else
' MessageBox("Are you sure you want to delete this incident?")
'Get the VehicleId of the row whose Delete button was clicked
'Dim SelectedIncidentId As …Run Code Online (Sandbox Code Playgroud)