CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 HOWTO : Dependant listboxes

Print topic Send  topic

Author Message
Walter Kempees
Posted: 07/27/2004, 6:14 AM

Using the example tables below this would be a/my approach:
Assuming that the main table, the one the search and grid runs on has a
layout of
members(id, name, countryid, stateid, districtid, townid, .......)
country(id,country)
state (id,country,state)
district (id,state,ditrict)
town (id,district,town)

Create, using the builder a search/grid on MEMBERS with country, state,
district, town as search fields and
id, name, country, state, district, town as fields in the list.
Now first make everything work as normally, in the process, in the GRID,
changing the countryid, stateid, districtid and townid to displaying the
lookup values of the respective tables.
Only if you didn't do this in the builder already.
This will involve changing the SQL in the list to link to the respective
tables.
Get this to work first.
Next change the SQL in the list and add a where clause.
If this search/grid is generated, the search field will be called
s_countryid, s_stateid, s_districtid and s_townid and the SQL will be
already in place.
Change (or add) the where clause to:
members.countryid={s_countrid} and
members.stateid = {s_stateid} and
members.districtid = {s_districtid} and
members.townid = {s_townid}

Now save, generate and test your search/grid, any values given in the search
fields should result in the correct data in the grid.

Next in the Search part of the page, change the search field s_scountryid to
type: list box.
In the properties, data section, Click the datasource elipsis (...) ,
DataSourceType should be SQL,
statement SELECT id, country FROM country
Bound Column =
Text column =
Data Type = Text

Save, generate and test.
Should result in the same working page, except that for country you can
choose values from a list.

Next:
in the Search part of the page, change the search field s_stateid to type
list box.
In the properties, data section, Click the datasource elipsis (...) ,
DataSourceType should be SQL,
statement SELECT id, state FROM state where countryid = {s_country_id}
While changing this look at the Parameter section of the DataSource Window,
click the '+' sign to add a parameter.
Variable should be s_countryid, type Integer, Parameter s_countryid, Type
Control, give it a default value.
click ok and in the Properties, Data check
Bound Column =
Text column =
Data Type = Text

Following this scheme do the same for district and town.

It pays off to do a save, generate test after each step. Although
progressing slowly at least you will know where things go wrong if they do.

If all is well this should be the result upto now:
If you enter your page for the first time all list boxes will display the
default value (Select value).
Choose a value from country listbox and press SEARCH button, the screen
refreshes and displays your chosen value in country listox, now click the
state box
if all is well this should display choices only related to the value in
country, and so on displaying the appropriate records in the grid as you go
along.

If this works, then you are ready for the final step.
Simple and final step, go to the property window for each listbox, events
tab.
In the Client side events of the listbox you will find OnChange action,
right click this and choose [add action], the action you want is [submit
form].
Do this for each box and your search/grid with dependant listboxes should
work like a charm.

Donated
Walter



Damian
Posted: 07/27/2004, 7:44 AM

Awesome - Im working on a project almost identical to the one you have
outlined! Thanks Walter!

"Walter Kempees" <kempe819@planet.nl> wrote in message
news:ce5kgb$37q$1@news.codecharge.com...
> Using the example tables below this would be a/my approach:
> Assuming that the main table, the one the search and grid runs on has a
> layout of
> members(id, name, countryid, stateid, districtid, townid, .......)
> country(id,country)
> state (id,country,state)
> district (id,state,ditrict)
> town (id,district,town)
>
> Create, using the builder a search/grid on MEMBERS with country, state,
> district, town as search fields and
> id, name, country, state, district, town as fields in the list.
> Now first make everything work as normally, in the process, in the GRID,
> changing the countryid, stateid, districtid and townid to displaying the
> lookup values of the respective tables.
> Only if you didn't do this in the builder already.
> This will involve changing the SQL in the list to link to the respective
> tables.
> Get this to work first.
> Next change the SQL in the list and add a where clause.
> If this search/grid is generated, the search field will be called
> s_countryid, s_stateid, s_districtid and s_townid and the SQL will be
> already in place.
> Change (or add) the where clause to:
> members.countryid={s_countrid} and
> members.stateid = {s_stateid} and
> members.districtid = {s_districtid} and
> members.townid = {s_townid}
>
> Now save, generate and test your search/grid, any values given in the
search
> fields should result in the correct data in the grid.
>
> Next in the Search part of the page, change the search field s_scountryid
to
> type: list box.
> In the properties, data section, Click the datasource elipsis (...) ,
> DataSourceType should be SQL,
> statement SELECT id, country FROM country
> Bound Column =
> Text column =
> Data Type = Text
>
> Save, generate and test.
> Should result in the same working page, except that for country you can
> choose values from a list.
>
> Next:
> in the Search part of the page, change the search field s_stateid to type
> list box.
> In the properties, data section, Click the datasource elipsis (...) ,
> DataSourceType should be SQL,
> statement SELECT id, state FROM state where countryid = {s_country_id}
> While changing this look at the Parameter section of the DataSource
Window,
> click the '+' sign to add a parameter.
> Variable should be s_countryid, type Integer, Parameter s_countryid, Type
> Control, give it a default value.
> click ok and in the Properties, Data check
> Bound Column =
> Text column =
> Data Type = Text
>
> Following this scheme do the same for district and town.
>
> It pays off to do a save, generate test after each step. Although
> progressing slowly at least you will know where things go wrong if they
do.
>
> If all is well this should be the result upto now:
> If you enter your page for the first time all list boxes will display the
> default value (Select value).
> Choose a value from country listbox and press SEARCH button, the screen
> refreshes and displays your chosen value in country listox, now click the
> state box
> if all is well this should display choices only related to the value in
> country, and so on displaying the appropriate records in the grid as you
go
> along.
>
> If this works, then you are ready for the final step.
> Simple and final step, go to the property window for each listbox, events
> tab.
> In the Client side events of the listbox you will find OnChange action,
> right click this and choose [add action], the action you want is [submit
> form].
> Do this for each box and your search/grid with dependant listboxes should
> work like a charm.
>
> Donated
> Walter
>
>
>
>


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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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