Drop-down box dependent on the option selected in another drop-down box

后端 未结 7 1802
半阙折子戏
半阙折子戏 2020-11-29 05:55

I have 2 different SELECT OPTION in a form.

The first one is Source, the second one is Status. I would like to have different OPTIONS in my Status drop-down list dep

7条回答
  •  广开言路
    2020-11-29 06:50

    Try something like this... jsfiddle demo

    HTML

    
    
    
    
    
    

    JS

    $(document).ready(function () {
    
        $("#source").change(function () {
            var el = $(this);
            if (el.val() === "ONLINE") {
                $("#status").append("");
            } else if (el.val() === "MANUAL") {
                $("#status option:last-child").remove();
            }
        });
    
    });
    

提交回复
热议问题