2

確認ボックスの追加

これが私のコードで、確認ボックスを追加したいと思います。

私は2つのボタンを持つフォームを持っていsubmitます。確認ボックスが必要で、次のページに進みます。これどうやってするの?これは確認ボックスのコードですが、フォームに配置するにはどうすればよいですか?

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>
4

5 に答える 5

2

On button class try this

$('.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();
  }
});
于 2013-01-08T09:38:03.073 に答える
0

次のスニペットが解決策です。this.form.submit()ボタンは送信ボタンであり、デフォルトでは送信されるため、削除する必要があります。

フォームに追加して、送信ボタンからonsubmit=" return window.confirm('Are you sure?');"削除するだけです。this.form.submit()

<form id="form1" name="form1" method="post" action="" onsubmit=" return window.confirm('Are you sure?');">
                        <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';" />
            </label>
                                <br />

                            </br>
                   <label>
                 <input type="submit" name="Submit" value="Delete" onclick="this.form.action='delete1.jsp?flag=1&act=1';" />
           </label>
                                <br/>

                        </div></form>
于 2013-01-08T09:33:34.957 に答える
0
See this code confirm box works in this way and one sugesstion your code need a lot pf improvement

<html>
<head>
<script>
function disp_confirm()
{
var r=confirm("Press a button!")
if (r==true)
  {
  alert("You pressed OK!")
  }
else
  {
  alert("You pressed Cancel!")
  }
}
</script>
</head>
<body>

<input type="button" onclick="disp_confirm()" value="Display a confirm box">

</body>
</html> 
于 2013-01-08T09:36:45.623 に答える
0

これを試して

<form id="form1" name="form1" method="post" action="/your/url.xyz" onsubmit="return confirm('bla bla');">
于 2013-01-08T09:26:55.563 に答える
0
<input type="submit" name="Submit" value="Delete" onclick='confirm(this,"delete1.jsp?flag=1&act=1")' />
<input type="submit" name="Submit" value="delete" onclick='confirm(this,"logi.jsp?flag=1&act=1")' />

function confirm(this,foo1)
{
var foo = confirm('Are you sure?');
if (foo) {this.form.action=foo1;this.form.submit();}
else {alert('Try Later');}
}
于 2013-01-08T09:30:57.520 に答える