Hello i have to make 3 select input with the same "option text" but value is different. i want to make disabled item on other select when is selected on one of this i have try this but not work : jsfiddle Test
inspired by this: This jsfiddle
$(".activ select").on('focus', function ()
{
previous = this.options[this.selectedIndex].innerHTML;
}).change(function() {
var previoues_tx = previous;
var selected = $(this).find('option:selected').text();;
var opts = $(this)[0].options;
var array = $.map(opts, function(elem) {
return (elem.text || elem.text);
});
//alert(previoues_tx);
//alert(selected);
//alert(opts);
//alert(array);
$('.activ select').each(function() {
var oki = $(this).text();
if(previoues_tx != 'Choisir---------------' )
//alert(oki);
{
$('select option[text="' + previoues_tx + '"]').removeAttr('disabled');
}
$('select option[text="' + selected + '"]').attr('selected','selected').attr('disabled', true);
$('select option[text=""]').removeAttr('disabled');
});
previous = this.options[this.selectedIndex].innerHTML;
});
Problem is in the reference JsFiddle, similar option for all select
box contain same value but in your case you kept as different.
I modified your example see demo here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.