Copy link to clipboard
Copied
Scenario:
I have 5 list boxes and they are linked hierarchically.
Continent >> Country >> State >> Capital >> Post code
Master list box: Continent names
Dependent 1 list box: Country names
Dependent 2 list box: State names
Dependent 3 list box: Capital names
Dependent 4 list box: post/zip codes
Continent >> Country >> State >> Capital >> Post code
The master list box has 6 continent names and rest of the each list box is populated with 75+ list items for country names, capital names, multiple zip codes within each city.
Currently all list boxes from master list box to Dependent4 list box are connected in hirarchy oder and works perfectly.
when I select Continent name is Master list box, I get right country names in Dependent1 list box. When I select the specific country in Dependent1 list box, I get the right state names in Dependent2 list box and so on....
Sample Example:
Master list box >> Dependent1 list box >> Dependent2 list box >> Dependent3 list box >> Dependent4 list box
North America >> USA >> District of Columbia >> Washington DC >> 20013
North America >> USA >> District of Columbia >> Washington DC >> 20011
----------------------------------------------------------------------------------------------------
I have added a Text Box and using it as a search box so that the user can key in CONTINENT NAME or COUNTRY NAME or CAPITAL NAME or CITY NAME or ZIP CODE and based on a valid search result, each respective list box should display related list items in Master, Dependent1, Dependent2, Dependent3, and Dependent 4 list box.
Example 1:
If the user key in 20017 in the search box, each list box should filter list items and should show:
Continent = North America
Country = USA
State = District of Columbia
Capital = Washington DC
Zip Code = 20017
Example 2:
If the user key in New Delhi in the search box, each list box should filter list items and should show:
Continent = Asia
Country = India
State = New Delhi
Capital = New Delhi
Zip Code = 110001
----------------------------------------------------------------------
I am using the following code in Text Search Box:
if(!event.willCommit)
{
var aFull = event.value.split("");
aFull.splice(event.selStart, event.selEnd - event.selStart, event.change);
var rgTest = new RegExp(aFull.join(""),"i");
if((aLst = aDataList.filter(function(a){return rgTest.test(a)})).length)
this.getField("masterListBox").setItems(aLst);
else
this.getField("masterListBox").clearItems();
}
And added all Continent names, Country names, State names, Capital city names, and zip codes in a Document Level Variable "aDataList".
Problem:
When I type the continent name in the search box, my Master list box shows the correct continent name, and the rest of the dependent list box remains blank. This is perfectly OK and it is expected behavior.
When I type the city name = Beijing, I am expecting the Dependent 3 list box should filter all city names and should show Beijing as the only list item in the Dependent 3 list box and similarly all other list boxes should show:
Master list box: Asia
Dependent 1 list box: China
Dependent 2 list box: Beijing
Dependent 3 list box: Beijing
Dependent 4 list box: 100000
However, currently, my Master list box shows Beijing instead of Asia and the rest of the dependent list box shows previous search results instead of showing co-related data of Beijing.
I am not sure where I am going wrong here. I don't want to use 4 search boxes ( one for each list box).
I am using the following code in Master List box to populate Dependent 1 list box data:
var dependentListBoxFieldName = "dependentListBox1";
var dependentListValues =
{
"Oceania": [
["Australia", "australia"],
["New Zealand", "new zealand"],
["Fiji", "fiji"]
],
"North America": [
["USA", "usa"],
["Canada", "canada"],
["Caribbean", "caribbean"]
],
"Europe": [
["Germany", "germany"],
["France", "france"],
["UK", "uk"]
],
"Asia": [
["India", "india"],
["China", "china"],
["Rusia", "russia"]
]
};
And similar type of code for State names, Capital City Names, and Zip codes is added in each dependent list box for State names, the capital city, and zip code.
Any ideas for what I should modify/ change so when user key in the continent name or country name or state name or capital name or zip code in the search box, If the user data is valid than each list box should filter related list item and should show the correct continent, country, state, capital, zip code.
Any code example may definitely help me.
Thanks in advance.
Copy link to clipboard
Copied
In your script you change only the list "masterListBox".