Solved

How to display yes or no dialog in javascript or jquery

Posted on 2014-03-04
5
1,967 Views
Last Modified: 2014-03-05
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
Comment
Question by:bujjigadu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 39905395
$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
 
LVL 7

Accepted Solution

by:
Kishan Zunjare earned 300 total points
ID: 39905420
Custom yes no dialogue box by using jQuery

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

Hope this helps
-Kishan
0
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 39905839
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
 

Author Comment

by:bujjigadu
ID: 39906607
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
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 39908250
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question