Hello,
I am using a form with a double category pulldown menu as follows:
Pulldown 1 = Regions
Pulldown 2 = Cities
Selecting a region in pulldown 1 will display the corresponding cities for pulldown 2. This now is working perfectly.
I also have an imagemap of Oahu on the left side of the page with hotspots on the regions. Right now if you click on a region the whole page reloads and a variable is fed to the javascript to update the pulldown (it works). What I would like is for the imagemap to use javascript to update the pulldown. Is this possible?
Here is a short sample of the javascript I am using for the form:
<SCRIPT LANGUAGE="JavaScript">
<!--
var supported = (window.Option) ? 1 : 0;
if (supported) {
var active;
var ar = new Array();
//
ar[0] = new Array();
ar[0][1] = new makeOption("CENTRAL OAHU (All Neighborhoods)", "central");
ar[0][2] = new makeOption("HONOLULU - Kapalama", "Honolulu!KAPALAMA");
// etc...
}
function makeOption(text, url) {
this.text = text;
this.url = url;
}
function relate(form) {
if (!supported) {
load(form, "regions");
return;
}
var options = form.city.options;
for (var i = options.length - 1; i > 0; i--) {
options = null;
}
var curAr = ar[form.regions.selectedIndex];
for (var j = 0; j < curAr.length; j++) {
options[j] = new Option(curAr[j].text, curAr[j].url);
}
options[0].selected = true;
}
// -->
</SCRIPT>
Here is the first pulldown (regions):
<SELECT NAME="regions" onChange="relate(this.form)" class="formtext">
<option value="" selected>All Regions
<option value="central">Central Oahu
<option value="diamondhd">Diamond Head
(etc...)
</select>
Here is the second pulldown (cities):
<select name="city" class="formtext">
(gets populated when the first pulldown is clicked)
</select>
Any help would be appreciated.
I am using a form with a double category pulldown menu as follows:
Pulldown 1 = Regions
Pulldown 2 = Cities
Selecting a region in pulldown 1 will display the corresponding cities for pulldown 2. This now is working perfectly.
I also have an imagemap of Oahu on the left side of the page with hotspots on the regions. Right now if you click on a region the whole page reloads and a variable is fed to the javascript to update the pulldown (it works). What I would like is for the imagemap to use javascript to update the pulldown. Is this possible?
Here is a short sample of the javascript I am using for the form:
<SCRIPT LANGUAGE="JavaScript">
<!--
var supported = (window.Option) ? 1 : 0;
if (supported) {
var active;
var ar = new Array();
//
ar[0] = new Array();
ar[0][1] = new makeOption("CENTRAL OAHU (All Neighborhoods)", "central");
ar[0][2] = new makeOption("HONOLULU - Kapalama", "Honolulu!KAPALAMA");
// etc...
}
function makeOption(text, url) {
this.text = text;
this.url = url;
}
function relate(form) {
if (!supported) {
load(form, "regions");
return;
}
var options = form.city.options;
for (var i = options.length - 1; i > 0; i--) {
options = null;
}
var curAr = ar[form.regions.selectedIndex];
for (var j = 0; j < curAr.length; j++) {
options[j] = new Option(curAr[j].text, curAr[j].url);
}
options[0].selected = true;
}
// -->
</SCRIPT>
Here is the first pulldown (regions):
<SELECT NAME="regions" onChange="relate(this.form)" class="formtext">
<option value="" selected>All Regions
<option value="central">Central Oahu
<option value="diamondhd">Diamond Head
(etc...)
</select>
Here is the second pulldown (cities):
<select name="city" class="formtext">
(gets populated when the first pulldown is clicked)
</select>
Any help would be appreciated.