Click to See Complete Forum and Search --> : conditionally setting a selection list to disabled


newname
07-09-2004, 01:38 PM
I've put the following line of script in the body of my document:

document.getElementByName("stateSelect").disabled = true;

stateSelect is a dropdown list that I want to disable if someone chooses Canada as their country in the previous selection list. At this point, I'm just trying to make the pieces work, and my line of code above isn't disabling the stateSelect list. I'm able to disable the list directly in html, by putting disabled = "true" in the <select> tag: why doesn't it do it from the line of code...
(my brain hurts)
Peter:confused:

schizo
07-09-2004, 01:45 PM
Hope this example helps.

<html>
<head>
<script>
function disableSelect(){
document.forms[0].selectBox.disabled = true;
}
</script>
</head>
<body onLoad="disableSelect();">
<form>
<select name="selectBox">
<option value="">--------------</option>
</select>
</form>
</body>
</html>

newname
07-09-2004, 01:52 PM
Thanks!!!!! That was quick!!!
:D