简体   繁体   English

警报框在JSP中不起作用

[英]alert box not working in jsp

I added a stylish alert box to my page, resource is here . 我在页面上添加了一个时尚的警告框,资源在这里 But problem is after clicking ok , confirmsubmit.jsp is not opening. 但是问题是单击okconfirmsubmit.jsp没有打开。 Also in that alert cancel button is not appearing why? 还在那个警报cancel按钮中为什么没有出现?

javascript javascript

  <form action="confirmsubmit.jsp" method="POST">
    <script type="text/javascript">
    <!--
    function confirmation() {
    var answer = csscody.alert("Confirm submit?")// added csscody here for alert but after clicking ok nothing happens
    if (answer){

     window.location = "confirmsubmit.jsp";
   }
   else{
     return false;// here cancel button is not coming
   }
     }
   //-->
   </script>
 </form>

html html

 <input type="text" name="textboxname"/>
 <input type="submit" onclick="return confirmation()"/> 
</form> 

UPDATE 更新

View below code ,it uses button instead of link 查看下面的代码,它使用按钮而不是链接

<form action="confirmsubmit.jsp" method="POST">
    <script type="text/javascript">
  $().ready(function() {
    $('#btn_submit').click(function(e) {

    e.preventDefault();
    var that = this;
    var text = "si o no compa?";
    csscody.confirm(text, {
        onComplete: function(e) {

            if (e) {
                window.location = "confirmsubmit.jsp";
            }
            else {
                return false;

            }


        }

    })
});
}); 
   </script>
   <input type="text" name="textboxname"/>
 <input type="submit" id="btn_submit" onclick="return confirmation()"/> 
 </form>

You willl have to use confirm instead of alert which will giv eyou both ok and cancel buttons which return true and false respectively. 您将必须使用confirm而不是alert ,这将使您分别单击确定取消按钮,分别返回truefalse And also take off return from onclick 并从onclick return

HTML 的HTML

<form action = "confirmsubmit.jsp" method = "POST">
    <input type = "text" name = "textboxname" />
    <input type = "submit" onclick = "confirmation();" />
</form>

Javascript Java脚本

function confirmation() {
   var answer = confirm("Confirm submit?");
   if (answer){
      window.location = "confirmsubmit.jsp";
   }
   else{
      return false;
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM