如果要使用 JSP 和 Java 脚本删除数据,则需要一个确认框

want a confirmation box, if you want to delete the data using jsp and java script

本文关键字:一个 确认 数据 JSP Java 如果 删除 脚本      更新时间:2023-09-26

我尝试了一些东西,但什么也没有得到。当我单击删除链接时,我必须得到一个确认框,但我没有得到它。谁能建议我?

.JSP

urlencrypt:url value="abc.action" htmlEscape="true" var="removeLink"/>
<td><a href="removeLink"  onclick="confirmRemoveQuestion('${removeLink}')">
<fmt:message key="link.remove" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>

JavaScript

<script type="text/javascript">
var confirmRemoveDialog;
var confirmOkUrl=  ; 
function setRemoveQuestionDialog()
{
    var handleYes = function() { 
        window.location = confirmOkUrl;
        this.hide(); 
    };
    var handleNo = function() { 
        this.hide();
    };
    var confDialogButtons = [ { text:"<fmt:message key="link.cancel"/>", handler:handleNo, isDefault:true}, 
                                { text:"<fmt:message key="link.ok"/>",handler:handleYes } 
                              ];
    confirmRemoveDialog = getConfirmOKDialog(confDialogButtons);
}
function confirmRemoveQuestion(url)
{
    confirmOkUrl = url;
    setRemoveQuestionDialog();
    showConfirmDialog(confirmRemoveDialog, "<fmt:message key="removeLink.confirmMessage"/>");
}
</script>

使用以下简单代码

<script>
function confirmRemoveQuestion(link){
    if(show_confirm()){
     window.location = link;
     this.hide(); 
    }
    else{
     this.hide();  
    }
}
function show_confirm()
{
  return confirm("Are you sure you want to do this?");
}
</script>
<td><a href="#"  onclick="confirmRemoveQuestion('${removeLink}')"> <!--removLink-->
<fmt:message key="link.remove" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>

你知道吗

showConfirmDialog(confirmRemoveDialog, "<fmt:message key="removeLink.confirmMessage"/>");

语法不正确吗?调试会告诉你这一点。

相关文章: