开发者

Using jQuery to disable multiple selects

开发者 https://www.devze.com 2022-12-18 16:49 出处:网络
I have 7 select menus. I want to have the user make three choices, leaving 4 select menus disabled. Here is the link: http://www.missionsolano.org/support_volunteer_form.php (under Areas of Interest).

I have 7 select menus. I want to have the user make three choices, leaving 4 select menus disabled. Here is the link: http://www.missionsolano.org/support_volunteer_form.php (under Areas of Interest).

I open to using jQuery form validator plu开发者_JAVA百科gins as well. Anyone have any tips?


This seems to work for me.

$('.aoi_select').change(function(){
    var totalSelected = $('.aoi_select[selectedIndex!=0]').length;
    if (totalSelected >= 3)
        $('.aoi_select[selectedIndex=0]').attr('disabled', 'disabled');
    else
        $('.aoi_select').removeAttr('disabled');
});
0

精彩评论

暂无评论...
验证码 换一张
取 消