Mr.M
Mr.M

Reputation: 1490

In the first drop down value has sub element then user select same value in the second drop down should accept using jquery

I have two html select option drop down if user select one of the html value as DIP EDU and in the second row html drop down value as DIP EDU an alert should come With my current code this was working but in some case for the first drop down some of the option value might have sub element for example if user select MBA from the first drop down user can see value in sub element Concentration testMBA now if user select any of same value in the second drop down it should allow the user.

I am confused here is the fiddle link

here is the jquery code

$(document).on('change','select.slt_major',function(event) {
            var _found = false;

            var cI = $(this);
            var others=$('select.slt_major').not(cI);
            $.each(others,function(){
               if($(cI).val()==$(this).val() && _found == false)
               {
                   $(cI).val('');
                   $('.slt_mjr1,.slt_mjrpg1,slt_mjrpg').val('0')
                   $('.mjr_Desc1,.mjr_Desc,.mjr_Descpg1').val('');
                   $('.pl_Stus1').val('');
                   alert('Major already selected');
                   _found = true;
               }
            });
        });   

Upvotes: 1

Views: 57

Answers (1)

Man Programmer
Man Programmer

Reputation: 5356

http://jsfiddle.net/ewsbs57f/1/

if (!$('#slt_ctr').val() && $(cI).val() == $(this).val() && _found == false)

Upvotes: 1

Related Questions