Here is my Php code
<?php
$menu_items = $this->db->get('menu_items');
$menuOptions ='<select class="item_id" name="item_id[]">';
$menuOptions .='<option value="">-- Select a Menu item --</option>';
foreach ($menu_items->result() as $row) {
$menuOptions.= '<option value="'.$row->code.'">'.$row->name.'</option>';
}
$menuOptions.='</select>';
?>
I will echo this $menuOptions string to display select box with same values , i am having more than 10 select boxes in same page with same values
if i selected a value in one dropdown, the value should disabled in all 10 select boxes in that page
Here is the code which i tried but seems to be not fetching the value from second select box, it is fetching only the first select box selected value as because of class name is same,
$(".item_id").change(function () {
var selected=$('.item_id option:selected').val();
$('.item_id').each(function() {
$('option[value="' + selected + '"]').attr('disabled','disabled');
});
});
is there any way to disabled in jquery after it gets selected