title: How can we check which button is clicked in a jQuery UI dialog box?
body: <p>I am trying to use jQuery UI to build a dialog box with Yes/No button for user confirmation. (This is because I want to make the UI uniform, as I have used jQuery UI to build the warning dialog boxes.) My intention is to ask for user confirmation if a large number (1000 or above) is submitted in the text box. So far my JavaScript code looks like this:</p>
  
  <pre><code>function checkclick(button1, button2, theForm) {
     var val;
     val = theForm.mybox.value;
     v = parseInt(val) || 0;
     var btns = {};
     btns[button1] = function(){ 
        $(this).dialog('close');
     };
     btns[button2] = function(){ 
        $(this).dialog('close');
     };
  
     if (v &gt;= 1000) {
        $('#dialog').dialog({
           autoOpen: true,
           modal:true,
           buttons:btns
        }); 
        $('#dialog_link').click(function () {
            $('#dialog').dialog('open');
        });
        return false;
     }
     return true;
  }
  </code></pre>
  
  <p>And my HTML looks like this:</p>
  
  <pre><code>&lt;div id='dialog' title='Note' style='display:none'&gt;
  &lt;p id='dialog_link'&gt;This is a very large number. Are you sure?&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;form name='myForm' action='result.php' method='post' 
   onsubmit="return checkclick('Yes', 'No', this)"&gt;
  &lt;input type='text' name='mybox'&gt;
  &lt;input type='submit'&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The problem is, when the user clicks either of the Yes or No button, it will go back to the same page. However, if I change the 'return false' to 'return true' inside the 'if' part, once the Submit button is clicked, the page will go directly to result.php without waiting for the user to click the Yes or No buttons. Is there any way to check which button is being clicked by the user, so that the page will go to result.php after clicking Yes, but remaining at the current page after clicking No?</p>