Click to See Complete Forum and Search --> : Disable / Enable Combo based on previous combo value


Dashe
09-14-2003, 05:10 PM
I am trying to get 4 combo boxs (Named: BlockA - BlockD) in a form to work in the following way.

Each Combo Box has 4 options one of which is "None". Basically when the page starts I want to get the first Combo Box (BlockA) to be active and it set the rest to "None" and have them disabled. If a use picks another option from BlockA that is not "None" the second combo (BlockB) becomes active and the same applies to the rest, if Block B is then changed to something else Block C gets active and vise versa. I have been trying to do this for a while now, all I can find is how to activate / deactivate a combo box based on a check box, any help would be appreciated

Thanks - Dashe

Khalid Ali
09-14-2003, 05:30 PM
get the reference to the list box

var lb = document.formName.listBoxName;

now if the changed value in this list box is anything other then none then display the second list box

//get selected value from the list box.
var value = lb.options[lb.selectedIndex].value;

//now see if its "none"

if(value!="none"){
//now display the other list box
document.formName.2ndListBox.style.visibility="visible";
}

repeat the above for all of them

make sure that all list box elements look like this in the html

<select name="2ndListBox" style="visibility:hidden;">

since you wanted them to be invisible at the load of the page.

The above will work..
:D

Dashe
09-14-2003, 05:39 PM
Thank you for such a fast reply

I understand what you are saying ( i think ) but how would that script work with the on change bit of the select tag, cause it would have to recheck if the value for itself after its is changed to see if it needs to enable or disable another box

Thanks again - Dashe