My contemplations and diurnal novelties are publicized here

Archive for the ‘Tips&Tricks’ Category

How to disable selection for specific elements in a drop downlist


Its pretty simple all you need to do is to add

disabled=”disabled”

You can remove similar items from other dropdown using following code

$(‘#ddl1’).change(function() {
$(“# ddl2 > option”).each(function(){
if($(‘# ddl1 option:selected’).text() == this.text)
{
$(this).attr(‘disabled’,’disabled’);
}
else
{
$(this).removeAttr(‘disabled’);
}
});

To that specific element which you want to disable

<select id=”CIlof” name=”CIlof”>
<option label=”Please Select” value=””>Please Select</option>
<option label=”LABEL-1″ value=”001-LABEL”>LABEL</option>
<option disabled=”disabled” value=”005-VALUE2″ label=”LABEL-2″>LABEL-2</option>
</select>

Advertisements
%d bloggers like this: