Hi,
I have a downloaded a small script which builds two interdependent menus - ie selecting an item from the first list changes what appears on the 2nd list. I have adapted it so the options available are pulled from a database.
If I want UK to be selected by default on the first list of course that is very easy but is it possible to change this so Manchester was selected by default on the 2nd list when the page loads?
Thanks very much
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">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", "Los Angeles|loangelesvalue", "Chicago|chicagovalue", "Houston|houstonvalue", "Austin|austinvalue"]
Stages[2]=["Vancouver|vancouvervalue", "Tonronto|torontovalue", "Montreal|montrealvalue", "Calgary|calgaryvalue"]
Stages[3]=["London|londonvalue", "Glasgow|glasgowsvalue", "Manchester|manchestervalue", "Edinburgh|edinburghvalue", "Birmingham|birminghamvalue"]
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])
}
}
</script>
I have a downloaded a small script which builds two interdependent menus - ie selecting an item from the first list changes what appears on the 2nd list. I have adapted it so the options available are pulled from a database.
If I want UK to be selected by default on the first list of course that is very easy but is it possible to change this so Manchester was selected by default on the 2nd list when the page loads?
Thanks very much
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">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", "Los Angeles|loangelesvalue", "Chicago|chicagovalue", "Houston|houstonvalue", "Austin|austinvalue"]
Stages[2]=["Vancouver|vancouvervalue", "Tonronto|torontovalue", "Montreal|montrealvalue", "Calgary|calgaryvalue"]
Stages[3]=["London|londonvalue", "Glasgow|glasgowsvalue", "Manchester|manchestervalue", "Edinburgh|edinburghvalue", "Birmingham|birminghamvalue"]
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])
}
}
</script>