function ff_CselRegion_action(element, action)
{
country = ff_getElementByName('CselCountry');
state = ff_getElementByName('CselState');
var America_NorthArray = new Array('Antigua and Barbuda', 'Canada', 'Greenland', 'USA', 'Mexico');
if (element.value == 'none') {
// drop countries
while (country.options.length > 0)
country.options[country.options.length-1] = null;
} else {
// get the matching array
var selectedArray = eval(element.value+'Array');
// drop supernumerous option
while (selectedArray.length <= country.options.length-1)
country.options[country.options.length-1] = null;
// add the new options
country.options[0] = new Option('Select Country', 'none', true, true);
for (var i = 0; i < selectedArray.length; i++)
country.options[i+1] =
new Option(selectedArray[i], selectedArray[i]);
} // if
// drop states
while (state.options.length > 0)
state.options[state.options.length-1] = null;
} // ff_CselRegion_action
function ff_CselCountry_action(element, action)
{
state = ff_getElementByName('CselState');
var stateArray_Antigua_and_Barbuda = new Array(
'Saint George', 'Saint John', 'Saint Mary', 'Saint Paul'
var selectedArray = eval('stateArray_'+element.value);
if (selectedArray == null) {
while (state.options.length > 0)
state.options[(state.options.length - 1)] = null;
} else {
// drop supernumerous option
while (selectedArray.length <= state.options.length-1)
state.options[state.options.length-1] = null;
// add the new options
state.options[0] = new Option('Select State', 'none', true, true);
for (var i=0; i < selectedArray.length; i++)
state.options[i+1] = new Option(selectedArray[i], selectedArray[i]);
} // if
} //ff_CselCountry_action
I am facing an issue with
var stateArray_Antigua_and_Barbuda
because of the spaces causing a problem in identifying 'Antigua and Barbuda' in the var America_NorthArray
. As I am relatively new to programming, I would appreciate simple solutions. Thank you beforehand.
P.S. Despite searching online, I have been unable to resolve this.