Hi,
I've done a bit of research and it seems there are two extra boolean values you can use when creating options on a dropdown menu. The 3rd one being whether it is the default selection and the 4th is whether it is selected or not.
I thought by populating my array with these values I would be able to specify which one would be selected. so for example if the US is selected Los Angelese is the default option, Canada would give Toronta etc. The problem is it always selects the last item in the list by default - where am I going wrong?
Thanks
Ed
<form name="addtmform">
<select name="Area" size="4" onChange="UpdateStages(this.selectedIndex)" style="width: 150px">
<option selected>Select A City</option>
<option value="usa">USA</option>
<option value="canada" SELECTED>Canada</option>
<option value="uk">United Kingdom</option>
</select>
<select name="Stages" size="4" style="width: 150px" onClick="alert(this.options[this.options.selectedIndex].value)">
</select>
</form>
<script type="text/javascript">
var Arealist=document.addtmform.Area
var Stageslist=document.addtmform.Stages
var Stages=new Array()
Stages[0]=""
Stages[1]=["New York|newyorkvalue|false|false", "Los Angeles|loangelesvalue|false|true", "Chicago|chicagovalue|false|false", "Houston|houstonvalue|false|false", "Austin|austinvalue|false|false"]
Stages[2]=["Vancouver|vancouvervalue|false|false", "Tonronto|torontovalue|false|true", "Montreal|montrealvalue|false|false", "Calgary|calgaryvalue|false|false"]
Stages[3]=["London|londonvalue|false|false", "Glasgow|glasgowsvalue|false|true", "Manchester|manchestervalue|false|false", "Edinburgh|edinburghvalue|false|false", "Birmingham|birminghamvalue|false|false"]
function UpdateStages(SelectedStageGroup){
Stageslist.options.length=0
if (SelectedStageGroup>0){
for (i=0; i<Stages[SelectedStageGroup].length; i++)
Stageslist.options[Stageslist.options.length]=new Option(Stages[SelectedStageGroup].split("|")[0], Stages[SelectedStageGroup].split("|")[1], Stages[SelectedStageGroup].split("|")[2], Stages[SelectedStageGroup].split("|")[3])
}
}
</script>
I've done a bit of research and it seems there are two extra boolean values you can use when creating options on a dropdown menu. The 3rd one being whether it is the default selection and the 4th is whether it is selected or not.
I thought by populating my array with these values I would be able to specify which one would be selected. so for example if the US is selected Los Angelese is the default option, Canada would give Toronta etc. The problem is it always selects the last item in the list by default - where am I going wrong?
Thanks
Ed
<form name="addtmform">
<select name="Area" size="4" onChange="UpdateStages(this.selectedIndex)" style="width: 150px">
<option selected>Select A City</option>
<option value="usa">USA</option>
<option value="canada" SELECTED>Canada</option>
<option value="uk">United Kingdom</option>
</select>
<select name="Stages" size="4" style="width: 150px" onClick="alert(this.options[this.options.selectedIndex].value)">
</select>
</form>
<script type="text/javascript">
var Arealist=document.addtmform.Area
var Stageslist=document.addtmform.Stages
var Stages=new Array()
Stages[0]=""
Stages[1]=["New York|newyorkvalue|false|false", "Los Angeles|loangelesvalue|false|true", "Chicago|chicagovalue|false|false", "Houston|houstonvalue|false|false", "Austin|austinvalue|false|false"]
Stages[2]=["Vancouver|vancouvervalue|false|false", "Tonronto|torontovalue|false|true", "Montreal|montrealvalue|false|false", "Calgary|calgaryvalue|false|false"]
Stages[3]=["London|londonvalue|false|false", "Glasgow|glasgowsvalue|false|true", "Manchester|manchestervalue|false|false", "Edinburgh|edinburghvalue|false|false", "Birmingham|birminghamvalue|false|false"]
function UpdateStages(SelectedStageGroup){
Stageslist.options.length=0
if (SelectedStageGroup>0){
for (i=0; i<Stages[SelectedStageGroup].length; i++)
Stageslist.options[Stageslist.options.length]=new Option(Stages[SelectedStageGroup].split("|")[0], Stages[SelectedStageGroup].split("|")[1], Stages[SelectedStageGroup].split("|")[2], Stages[SelectedStageGroup].split("|")[3])
}
}
</script>