How to create multiple selector dropdown in HTML using Jquery

Single Selection in Dropdown and get value in Alert Box

HTML CODE

                    

<select class=”form-control min-select” name=”dropdown_single”>
<option value=”pizza”>Pizza</option>
<option value=”burger”>Burger</option>
<option value=”hotdog”>Hot Dog</option>
</select>

Jquery  CODE

                    

<script type=”text/javascript”>

$(document).ready(function(){
$(‘select[name=”dropdown_single”]’).change(function() {
alert($(this).val())
});

</script>

Multiple Selection in Dropdown and get value in Alert Box

HTML CODE

                    

<select class=”form-control min-select” multiple name=”dropdown_multi[ ]”>
<option value=”pizza”>Pizza</option>
<option value=”burger”>Burger</option>
<option value=”hotdog”>Hot Dog</option>
</select>

 

Jquery  CODE

                    

<script type=”text/javascript”>

$(document).ready(function(){
$(‘select[name=”dropdown_multi[]”]’).change(function() {
alert($(this).val())
});
});

</script>

Leave a Reply

Your email address will not be published. Required fields are marked *