views:

18

answers:

2

I have two selection boxes in the same form. I would like 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.

+1  A: 

You can use jQuery and do something like this

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

more info here http://jquery.com/

Matt Williamson
A: 

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';
    }
}
Mathias Bak