CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Dependent listbox

Print topic Send  topic

Author Message
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/
>

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.