How to disable multiple options in one select. For example i have 2 selects with 5 and 3 options. So if i select 3rd option in second select, i want to disable 3rd,4th and 5th o
Also you can disable them:
var ary=[3,4,5];
$('[name=smjer] option').filter(function(){
return ($.inArray(parseInt(this.value),ary) >-1);
}).prop('disabled', true);
You can just hide them :
var ary = [3, 4, 5];
$('[name=smjer] option').filter(function () {
return ($.inArray(parseInt(this.value), ary) > -1);
}).hide();
and when again required show it:
var ary = [3, 4, 5];
$('[name=smjer] option').filter(function () {
return ($.inArray(parseInt(this.value), ary) > -1);
}).show();
To make it even better, you can do this:
var ary = [3, 4, 5];
// Get the options to be hidden/shown
var $options = $('[name=smjer] option').filter(function () {
return ($.inArray(parseInt(this.value), ary) > -1);
});
// Hide the options
$options.hide();
// Show the options
$options.show();