javascript - 如何在提交按钮之前添加确认框?

标签 javascript html

添加确认框

这是我的代码,我想向其中添加一个确认框。

我有一个带有两个提交按钮的表单。我需要他们的确认框,然后发送到下一页。我怎样才能做到这一点? 这是确认框的代码,我如何将其放入我的表单中?

onclick="return confirm('Are you sure?');"

myform.jsp

<form id="form1" name="form1" method="post" action="">
    <p>&nbsp;</p>
    <p align="center">Enter your choice:-
    <label> <br />
    <label>
       <input type="submit" name="Submit" value="delete" onclick="this.form.action='logi.jsp?flag=1&act=1';this.form.submit();" />
    </label>
    <br />
    </br>
    <label>
        <input type="submit" name="Submit" value="Delete" onclick="this.form.action='delete1.jsp?flag=1&act=1';this.form.submit();" />
    </label>
    <br/>
    </div>
</form>

最佳答案

在按钮类上尝试这个

$('.class').appendTo('body')
  .html('<div><h6>Yes or No?</h6></div>')
  .dialog({
  modal: true, title: 'message', zIndex: 10000, autoOpen: true,
  width: 'auto', resizable: false,
  buttons: {
      Yes: function () {
          doFunctionForYes();
          $(this).dialog("close");
      },
      No: function () {
          doFunctionForNo();
          $(this).dialog("close");
      }
  },
  close: function (event, ui) {
      $(this).remove();
  }
});

关于javascript - 如何在提交按钮之前添加确认框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14211792/

相关文章:

javascript - 创建一个自定义 Angular 原理图来生成以下划线开头的文件?

javascript - 如何轻松地将自定义字体放入 HTML5 Canvas 中?

javascript - 如何检测 RadioNodeList 值的变化?

javascript - 更新 ng 类上的特定对象

javascript - React ant-design 中的自动完成过滤器

html - 右文本对齐 mat-expansion-panel Material 组件

javascript - HTML5 Canvas 在完成呈现时会发出事件吗?

html - css 悬停样式和 iOS

javascript - 检测移动浏览器并更改CSS

javascript - Mocha 测试 'esm' 支持原生 ES6 模块