Hi guys,
I'm not a developer, but I managed to make it working a form with something similar. you select a region, than a country ad if there is the option you select a state
there is field "Region" with id: "CselRegion"
there is field "Country" with id: "CselCountry"
there is field "Province or State" with id: "CselState"
this is the action script for Region:
function ff_CselRegion_action(element, action)
{
country = ff_getElementByName('CselCountry');
state = ff_getElementByName('CselState');
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
this is the action script for Country:
function ff_CselRegion_action(element, action)
{
country = ff_getElementByName('CselCountry');
state = ff_getElementByName('CselState');
var africaArray = new Array(
'Ethiopia', 'Somalia', 'South Africa', 'Other'
);
var middleeastArray = new Array(
'Egypt', 'Iran', 'Israel', 'Kuwait', 'Lebanon', 'Morocco',
'Saudi Arabia', 'Syria', 'Turkey', 'U.A.Emirates', 'Other'
);
var asiaArray = new Array(
'Armenia', 'Bangladesh', 'Cambodia', 'China', 'India', 'Indonesia',
'Japan', 'Malaysia', 'Myanmar', 'Nepal', 'Pakistan', 'Philippines',
'Singapore', 'South Korea', 'Sri Lanka', 'Taiwan', 'Thailand',
'Uzbekistan', 'Vietnam', 'Other'
);
var europeArray = new Array(
'Albania', 'Austria', 'Belarus', 'Belgium', 'Bosnia', 'Bulgaria',
'Croatia', 'Cyprus', 'Czech Rep.', 'Denmark', 'Estonia', 'Finland',
'France', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland',
'Italy', 'Latvia', 'Liechtenstein', 'Lithuania', 'Luxembourg',
'Macedonia', 'Malta', 'Monaco', 'Netherlands', 'Norway', 'Poland',
'Portugal', 'Romania', 'Russia', 'Slovakia', 'Slovenia', 'Spain',
'Sweden', 'Switzerland', 'Ukraine', 'United Kingdom', 'Other'
);
var australiaArray = new Array('Australia', 'New Zealand', 'Other');
var lamericaArray = new Array(
'Costa Rica', 'Cuba', 'El Salvador', 'Guatemala', 'Haiti', 'Jamaica',
'Panama', 'Other'
);
var namericaArray = new Array('Canada', 'USA', 'Greenland', 'Mexico');
var samericaArray = new Array(
'Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador',
'Paraguay', 'Peru', 'Suriname', 'Uruguay', 'Venezuela', 'Other'
);
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 stateArrayUSA = new Array(
'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado',
'Connecticut', 'Delaware', 'Columbia', 'Florida', 'Georgia', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky',
'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan',
'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska',
'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon',
'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota',
'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
'West Virginia', 'Wisconsin', 'Wyoming'
);
var stateArrayGreenland = new Array(
'Avannaa (North)', 'Kitaa (West)', 'Tunu (East)'
);
var stateArrayMexico = new Array(
'(North)', '(West)', '(East)', '(South)'
);
var stateArrayCanada = new Array(
'Alberta', 'British Columbia', 'Manitoba',
'New Brunswick', 'Newfoundland and Labrador', 'Nova Scotia',
'Northwest Territories', 'Nunavut', 'Ontario', 'Prince Edward Island',
'Québec', 'Saskatchewan', 'Yukon'
);
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
that's work with my form, hope it helps
take care
|
-
giorgio25b
-
- OFFLINE
-
Fresh Boarder
-
- Posts: 5
-
Karma: 0
-
|