Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:59:15+00:00 2026-05-30T21:59:15+00:00

I need to give an alert when user clicks appropriate buttons. This is my

  • 0

I need to give an alert when user clicks appropriate buttons.

This is my plugin:

    (function($){

    // Defining our jQuery plugin

    $.fn.Message= function(prop){

        // Default parameters

        var options = $.extend({
            height : "250",
            width : "500",
            autoclose:false,
            type: "Success",
            success: function (result) { },
            title:"JQuery Modal Box Demo",
            description: "Example of how to create a modal box.",
            top: "20%",
            left: "35%",
            imagePath: 'images/success.png',
        },prop);


        return this.click(function(e){
            add_block_page();
            add_popup_box();

           setTimeout(function() {
          $('.JMesg').animate({top:'toggle'},80);
            },300);

               if(options.autoclose==true)
                {
                 setTimeout(function() { 
                 $('.close').trigger('click');
                },4000); 
                }

         });


         function add_block_page(){
            var block_page = $('<div class="page"></div>');
            $(block_page).appendTo('body');
        }

         function add_popup_box(){
             var pop_up = $('<div class="Message"><a href="#" class="close"></a><div class="header"><h3>' + options.title + '</h3></div><div class="mainbody"><table><tr><td><img src='+ options.imagePath +' class="mesgicon"/></td><td><p class="bodytext">' + options.description + '</p></td></tr></table></div><div class="footer"><a href="#" class="btn-close"><span>close</span></a></div></div>');
             $(pop_up).appendTo('.page');

              if(options.type=="Success"){
              var buttons =$('<a href="#" class="btn-Ok"><span>OK</span></a>');
               $(buttons).appendTo('.footer');
             }

              if(options.buttons=="Error"){
              var buttons =$('<a href="#" class="btn-Ok"><span>OK</span></a>');
               $(buttons).appendTo('.footer');
             }

             if(options.buttons=="Info"){
              var buttons =$('<a href="#" class="btn-Ok"><span>OK</span></a>');
               $(buttons).appendTo('.footer');
             }

              if(options.buttons=="Confirm"){
              var buttons =$('<a href="#" class="btn-Yes"><span>Yes</span></a><a href="#" class="btn-No"><span>No</span></a><a href="#" class="btn-Cancel"><span>Cancel</span></a>');
               $(buttons).insertBefore('.footer');
             }

              if(options.type=="Alert"){
              var buttons =$('<a href="#" class="btn-Ok"><span>OK</span></a>');
               $(buttons).appendTo('.footer');
             }

            $('.close').click(function(){
                 $(this).parent().animate({top:'toggle'},80);
                 setTimeout(function() {        
                  $('.page').fadeOut().remove();    
                },400);   
             });


              $('.btn-close').click(function(){
                 $(this).parent().parent().animate({top:'toggle'},80);
                 setTimeout(function() {        
                  $('.page').fadeOut().remove();    
                },400);      
             });

              $('.btn-Ok').click(function (e){
              e.preventDefault();
                 var value = $(this).val();
                 options.success(value);
                 $(this).parent().parent().animate({top:'toggle'},80);
                 setTimeout(function() {        
                  $('.page').fadeOut().remove();    
                },400);      
             });
        }
        return this;
     };
})(jQuery);

This is how I call:

<script type="text/javascript">
        $(document).ready(function () {
            $('.SuccessMessage').Message({
                type:"Success",
                autoclose: false,
                imagePath: 'images/success.png',
                title: 'Hoorah!',
                description: 'Success!.',
                success: function (result) {
                    if (result == "OK") {
                        alert("One cup of coffee coming right up!");
                    }
                }
            });
  </script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:59:16+00:00Added an answer on May 30, 2026 at 9:59 pm

    The value of .btn-Ok, which you are passing to your success callback, is an empty string. Try changing your click handler to pass the anchor tag’s text() instead:

    $('.btn-Ok').click(function (e){
        e.preventDefault();
        var value = $(this).text(); // pass text instead of value
        options.success(value);
        $(this).parent().parent().animate({top:'toggle'},80);
        setTimeout(function() {        
            $('.page').fadeOut().remove();    
        },400);      
    });
    

    Or hardcode the value passed to the success callback:

    options.success("OK");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to give user one alert after saving an item.So I am using
i am building a php based website but now i need to give user
I have an ajax function in home.php that give me back this html response
HTML CODE: <li id=list_id>List_text<img src='image.jpg' id=img_id></li> jQuery Function: $(#list_id).live('click' , function(){ alert('List is clicked');
I have this small problem with jquery: I need to do something like this:
How to use Java script alert msg in code behind? This message will be
I need to give the countdown as shown here , for each item using
In my page I need to give my current variable as parameter to the
I'm in a ASP.NET project where I need to give several parameters to the
I have a set of different interfaces and I need to give them access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.