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 6178121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:24:29+00:00 2026-05-24T00:24:29+00:00

I am designing a html page. I want to show a confirmation msg on

  • 0

I am designing a html page.
I want to show a confirmation msg on changing a drop down element using jquery or javascript.
Please help to do this.

I have code which will ask confirmation. On selecting cancel it will not select previous item of Drop down.

$("#dropdownId").change(function(e) 
{
        if($(this).val() == "40")
        {
            if(confirm("Are you sure"))
                return true;
            else
                return false;
        }
});

Thanks

  • 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-24T00:24:29+00:00Added an answer on May 24, 2026 at 12:24 am

    You should be able to store the previous value on the click event and set it back on the change event:

    var setLastSelected = function(element) {
       $(element).data('lastSelected', $(element).find("option:selected"));
    };
    
    $("select").each(function () {
       setLastSelected(this);
    });
    
    $("select").change(function(){        
          if(confirm("Are you sure")) { 
              setLastSelected(this);
              return true; 
          }
          else {
             $(this).data('lastSelected').attr("selected", true);
             return false;
          }
    });
    

    See: http://jsfiddle.net/w9JYX/14/

    Update: I updated the code to work more generically on a set of dropdown controls and also removed the click handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing a html page with strict doctype and there's a form element in
I am designing mobile webapp in HTML, Javascript, CSS & jQuery ... I am
I'm designing a very simple web page (HTML only), the only feature I want
I am designing a regular expression tester in HTML and JavaScript. The user will
What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google
I'm designing an HTML page for display in Android browsers. Consider this simple example
I am designing a small website using HTML + JSP. This is my first
In designing the HTML and CSS for a page, when should I use img.className
I'm designing my first page using CSS3, and I'm running into a snag. I
I'm a new comer to web designing. I created my web page layout using

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.