How to link 2 combo boxes...

How to link 2 combo boxes...

  
So the value selected in one drives the content in the other.

In my example, the user selects a state in the first box, then should be prompted for cities in that state by the second box.

I have a screen preparation query that retrieves states from the database to populate the first combo box.

Then I've tried to use an advanced query to select only cities for that state. The SQL is fine, but at runtime the second combo box is empty.

Thanks,
Tom
Hi,

Create a record list with the type of structure that you use on advanced query, then associate to the onchange event of the states combo box an action, that executes the advanced query to get cities, assign the result of advanced query to the record list variable and then use ajax refresh to update combo box. The source of combo box must be the record list variable.
A good example of that is the action refreshtable that comes with some template screens.

Nelson Inácio

Hi Tom,

 

Check the attached example.

 

You just have to setup an "OnChange" handler in the state combo box to a screen action that will query the database for the cities for that state, set the city record list variable with the output of the query and do an Ajax refresh on the City combo box.

 

For running the example, be sure to click in the "Load Sample data" button first.

 

Bye!

 

 

 

 

Hi Tom,

You've said that you have "a screen preparation query that retrieves states from the database to populate the first combo box." but how do you populate the second combo?


In which platform version are you working?