Lizam
|
| Posted: 10/22/2004, 8:25 PM |
|
On an editable record page, I have two dropdown listbox : State and City. Both values comes from a single lookup table as below:
id desc parent
1 state1 0
2 state2 0
3 city1 1
4 city2 1
5 city3 2
When a state is selected, only its cities wil be shown in the second listbox. In the On Change of the first listbox, call the same page and pass parameter containing the parent value to populate the second listbox. This works ok except that ONLY when the first time the page is loaded, I can't seem to filter the listbox for the city based on the state value. It lists all the records in the table instead.
In the Data Source for state listbox, the where clause is : parent=0, whereas for city listbox, its where clause is: parent = {State}.
Tried On Before Build Select of the city listbox but no luck:
if (CCGetParam("State") == '') {
$parent = $record->State->GetValue() ;
$record->City->ds->Where = " parent = " . $parent ;
}
Any ideas, workaround? Thanks in advance.
|
|
|
 |
greg
|
| Posted: 10/29/2004, 3:34 AM |
|
The database lookup occurs only on the server, when the page is created,
and when the user select something in the menu nothing happens on the
server (it's a client-side action). So you have 2 solutions: either
reload the page each time the user selects something in the first menu,
or load the whole list and write a javascript to fill to the second menu
according to the first one.
Greg
Lizam wrote:
> On an editable record page, I have two dropdown listbox : State and City. Both
> values comes from a single lookup table as below:
>
> id desc parent
> 1 state1 0
> 2 state2 0
> 3 city1 1
> 4 city2 1
> 5 city3 2
>
> When a state is selected, only its cities wil be shown in the second listbox.
> In the On Change of the first listbox, call the same page and pass parameter
> containing the parent value to populate the second listbox. This works ok
> except that ONLY when the first time the page is loaded, I can't seem to filter
> the listbox for the city based on the state value. It lists all the records in
> the table instead.
>
> In the Data Source for state listbox, the where clause is : parent=0, whereas
> for city listbox, its where clause is: parent = {State}.
>
> Tried On Before Build Select of the city listbox but no luck:
>
> if (CCGetParam("State") == '') {
> $parent = $record->State->GetValue() ;
> $record->City->ds->Where = " parent = " . $parent ;
> }
>
> Any ideas, workaround? Thanks in advance.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|