...

View Full Version : disable cascading selects



Lisawynn
03-15-2004, 03:46 PM
There are two drop down menus - the first has two options - Province and State. The second select changes to show the corresponding provinces/states. I need to disable the second select when Province is selected in the first select (basically, when the page loads). I have tried

if(document.form6.choose_category[0].selected==true)
{
document.form6.the_examples.disabled=true)
}

and have changed it around a couple of times but just seem to be missing something. If anyone can offer assistance, I would appreciate same. Thanks!!

Here is the code:


<html>
<script language="javascript">

var Province = new Array("British Columbia","Alberta","Saskatchewan","Manitoba","Ontario",
"Quebec","New Brunswick","Newfoundland","Prince Edward Island","Nova Scotia")
var States = new Array("Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut",
"Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine",
"Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire",
"New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island",
"South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia",
"Wisconsin","Wyoming");

function swapOptions(the_array_name)
{
var numbers_select = document.form6.the_examples;
document.form6.the_examples.length=50;
var the_array = eval(the_array_name);
setOptionText(document.form6.the_examples, the_array);
}

function setOptionText(the_select, the_array)
{
for (loop=0; loop < the_select.options.length; loop++)
{
the_select.options[loop].text = the_array[loop];
}
}

function disabled1(){
if(document.form6.Province[0].selected==true)
{ document.form6.the_examples.disabled==true

}
}
</script>
<body>
<form name="form6">
<p align=top>
<select name="choose_category"
onChange="swapOptions(document.form6.choose_category.options[selectedIndex].text);">
<option selected>Province
<option>States
</select>

<select name="the_examples">
<option>British Columbia
<option>Alberta
<option>Saskatchewan
<option>Manitoba
<option>Ontario
<option>Quebec
<option>New Brunswick
<option>Newfoundland
<option>Prince Edward Island
<option>Nova Scotia

</select>
</form>

</html>


Thanks Again!!!!!

Willy Duitt
03-15-2004, 05:40 PM
You could try:
if(document.form6.choose_category.selectedIndex==0)

.....Willy

Lisawynn
03-15-2004, 06:02 PM
That did not work but you gave me an idea and I tried this:

if(document.form6.choose_category.options[0].selected==true)

and now it works. Thanks very much!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum