Trying to create and additional OK & Cancel check from drop down menu

I am having some if and else statements inside a function like the following:

var dropdownSelectionItem = $("#name").val();
                  


                    

                    if (dropdownSelectionItem == "First") {
                        id_value = 1000;
                    }
                    else if (dropdownSelectionItem == "Second") {
                        id_value = 2000;
                    }
                    else if (dropdownSelectionItem == "Third") {
                        alert("Are you sure you want to select third option?");
                        id_value = 3000;
                    }
                    else if (dropdownSelectionItem == "Fourth") {
                        id_value = 4000;
                    }

In HTML I have the following :

 <select class="form-control" id="name">
               <option value="First">First</option>
                <option value="Second">Second</option>
                 <option value="Third">Third</option>  
		<option value="Fourth">Fourth</option>												
  </select>

What I am trying to achieve:

When a user selects Third" from the dropdown menu, I want to show an additional dialog which says Are you sure you want to select third option? which I am trying to attempt as shown above.

I am using the id_value later on in my code to make a webservice calls. Right now with my above code, it shows an alert and still passes the id-value when user click on OK button which is obvious.

Is it possible to have a dialog which shows the message with Ok or Cancel, so that when a user clicks on Cancel button, it should exit from the dropdown and should not proceed with passing id_value further in the code?

Thanks

Try to use a modal.I’ll give you a link with bootstrap modals to see.
http://www.jquery-az.com/bootstrap-modal-with-7-demos-online/

P.S
See and this
http://simplemodal.plasm.it/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.