[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2657
  • Last Modified:

How to display yes or no dialog in javascript or jquery

I have a button in my page like this

<div class="buttonHolder">
                        <input valign="center" name="Button3" id="btnSubmitchanges" type="button" value="Submit Changes" style="background-color:#A9E2F3; font-size: 12px; font-weight:bold; visibility:;"  />
       </div>

When I click the above button I want to display yes or no dialog box and wants to return the value based on user clicks 'yes' or 'no' button.

Thanks
0
bujjigadu
Asked:
bujjigadu
1 Solution
 
Minh Võ CôngCommented:
$mydialog = $("#dialog").dialog({
    autoOpen: false,
    buttons: {
        "ok": function() {
            $(this).dialog("close");
            processResult(true);
        },
        "cancel": function() {
            $(this).dialog("close");
            processResult(false);
        }
    }
});

$mydialog.dialog("open");


function processResult(result) {
    alert(result);
}
0
 
Kishan ZunjareCommented:
Custom yes no dialogue box by using jQuery

http://jsfiddle.net/kishanzunjare/tswrR/

Hope this helps
-Kishan
0
 
Albert Van HalenCommented:
Without jQuery and or jQuery.UI libraries a simple confirm would suffice.
<div class="buttonHolder">
    <input valign="center" name="Button3" id="btnSubmitchanges" type="button" value="Submit Changes" style="background-color:#A9E2F3; font-size: 12px; font-weight:bold; visibility:;"
onclick="return confirm('Are you sure ?');"  />
</div>

Open in new window

0
 
bujjigaduAuthor Commented:
Minh,

How to call this from the button

$mydialog = $("#dialog").dialog({
    autoOpen: false,
    buttons: {
        "ok": function() {
            $(this).dialog("close");
            processResult(true);
        },
        "cancel": function() {
            $(this).dialog("close");
            processResult(false);
        }
    }
});

$mydialog.dialog("open");


function processResult(result) {
    alert(result);
}
0
 
Minh Võ CôngCommented:
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now