开发者

Disable one Selection Box based on a Selection in another

I have two selection boxes in the same form. I would lik开发者_开发问答e to have one disabled based on some of the options that can be selected in the other selection box. I'm looking for a solution in JavaScript if possible.


You can use jQuery and do something like this

$('#select1').change(function() {
    if(...) {
        $('#select2').attr('disabled', 'disabled');
    }
});

more info here http://jquery.com/


And if you dont use jquery you can do it like this

<input type="checkbox" id="select1" onchange="disable()">

function disable() {
    if(...) {
        document.getElementById('select2').disabled='disabled';
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜