My code begins with a citySelectBox e.g.,
<option value="">-- select city --
<option value="-1">[-- change country --]
<option value="1">Washington
<option value="2">New York
<option value="3">Baltimore
<option value="4">Denver
etc
I have a problem if user clicks [-- change country --].
What I want is the following:
1) the existing citySelectBox must be replaced by a countrySelectBox
2) on change, the countrySelectBox must be replaced by a new citySelectBox with the new cities.
The detailed code follows (with my problem area commented out). Any help wiould be appreciated.
Thanks
New Kid on the Block
<option value="">-- select city --
<option value="-1">[-- change country --]
<option value="1">Washington
<option value="2">New York
<option value="3">Baltimore
<option value="4">Denver
etc
I have a problem if user clicks [-- change country --].
What I want is the following:
1) the existing citySelectBox must be replaced by a countrySelectBox
2) on change, the countrySelectBox must be replaced by a new citySelectBox with the new cities.
The detailed code follows (with my problem area commented out). Any help wiould be appreciated.
Thanks
New Kid on the Block
Code:
<!--
function loadCities(countryID){
if(countryID == "") {
displayCities("");
return;
}
var contentLoader = new ylib.util.ContentLoader(this,"/ajax/citiesServer.asp?c=" + countryID,cityCallback,null);
//var x = req.send("GET",,"",null,null,false,countryID,cityCallback,null);
contentLoader.SendRequest();
}
function cityCallback(request){
displayCities(request.responseText);
}
function displayCities(cityOptions) {
var citySelect = xGetElementById('ct');
xDisplay(citySelect,'block');
var cityDiv = xGetElementById('ctWrapper');
var selectBox = "";
if(cityOptions != '') {
selectBox = "<select name='ct' id='ct' onchange='this.form.submit();'><option value=''>-- select city --</option>" +
cityOptions +
"</select>";
}
cityDiv.innerHTML = selectBox;
}
-->
</script>
<form name="citySelect" method="GET" action="../en/city.asp" onsubmit="alert('submit to default page');return false;">
<table align="right" border="0">
<tr>
<!-- Problem area
<th>
<p id='ctWrapper'></p>
</th>
<th>
<select class="form" name='c' onchange='loadCities(this.options[this.selectedIndex].value);'>
<option value="">-- Select Country --</option>
<option value="63">USA - Central</option>
<option value="2">USA - North East</option>
<option value="61">USA - South East</option>
<option value="62">USA - West</option>
<option value="3">United Kingdom</option>
<option value="4">South Africa</option>
<%=list_DefaultCountryOptions("")%>
</select>
</th>
-->
<th>
<select name="ct" id="ct" onchange="submit()">
<option value=''>-- change city --</option>
<option value='-1'>[-- change country --]</option>
<%=list_CityOptions("")%>
</select>
</th>
</tr>
</table>
</form>