javascript - 想要一个确认框,如果你想使用jsp和java脚本删除数据

标签 javascript jsp

我尝试了一些但没有得到任何东西.. 当我点击删除链接时,我必须得到一个确认框,但我没有得到它.. 有人可以建议我吗?

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>

关于javascript - 想要一个确认框,如果你想使用jsp和java脚本删除数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19969821/

相关文章:

javascript - PHP 数组正确的 JSON 格式

javascript - TypeAhead.js 和 Bloodhound 显示奇数​​个结果

java - 使用struts2登录后重定向

java - 如何编写没有任何外部 View 组件的 portlet

javascript - Angular .js :88 Uncaught Error: [$injector:modulerr]

javascript - 制作实时聊天 php 的最佳方法?

javascript - 用于查找重复出现的多个非数字字符的正则表达式模式

java - 无法从选择框获取值到 servlet

php - JSP 还是 RUBY/PHP?

eclipse - Eclipse中JSP的格式化规则