Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  186] [ 2]  / answers: 1 / hits: 29015  / 10 Years ago, wed, june 4, 2014, 12:00:00

How can I open a model window by jquery onchange of select option???



Code for Modal window is here:



<div class=modal fade bs-example-modal-lg tabindex=-1 role=dialog aria-labelledby=myLargeModalLabel id=myModal style=display:none aria-hidden=true>
<div class=modal-dialog modal-lg>
<div class=modal-content>
Some Contents here..
</div>
</div>
</div>


Code for Select option is here:



<select id=selectbox>
<option value=0>- Select -</option>
<option value=1>yes</option>
<option value=2>No</option>
</select>

More From » jquery

 Answers
8

First you need to grab the jQuery UI dialog and put it in your (document).ready handler.



$('#dialog-modal').dialog({
modal: true,
autoOpen: false
});


After that, you define a function that says on .change() it should open the dialog:



$('select').change(function () {
$('#dialog-modal').dialog('open');
});


To say that it should open on 'yes', just put an if statement representing your 'yes' choice:



if ($(this).val() == 1) {
//...code...
}


DEMO


[#70739] Monday, June 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tammyb

Total Points: 278
Total Questions: 101
Total Answers: 103

Location: Botswana
Member since Sat, Jan 7, 2023
1 Year ago
;