Friday 20 June 2014

Select only 3 options in dropdown jquery php

Select only 3 options in dropdown jquery php

<script>

$("#destination_airport").on("change", function()
{
    var msg = $("#msg");
   
    var count = 0;
   
    for (var i = 0; i < this.options.length; i++)
    {
        var option = this.options[i];
       
        option.selected ? count++ : null;
       
        if (count > 3)
        {
            option.selected = false;
           
            msg.html("Please select at most three options.");
        }
    }
});
</script>

No comments:

Post a Comment