Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messagedatabase structure
Posted by: webgodjj (IP Logged)
Date: December 06, 2006 10:31AM

I really like that you use prototype for making the chained select boxes.

However, I am unsure on how this works.

1. Could you explain the logic of the database structure?
2. Another great thing would be a readme, or instructions on setting this up.

messageRe: database structure
Posted by: panos (IP Logged)
Date: December 07, 2006 02:50AM

Well...

Parent's table structure is a simple 2 field list key-descr.
But child's table should have an extra column in order to filter records.

For example if parent's data are industries (let's name table material_types):
id - descr
1 - Gas
2 - Solid

and child select box should be populated with sub-categories for each, then table (let's name table matterials) should be like:
id - parent_id - descr
1 - 1 - Neon
2 - 1 - Oxyzen
3 - 2 - Rock
4 - 2 - Glass
5 - 2 - Wood

So, when High Tech is selected on parent select box the query to fetch values for child would be
SELECT id, descr FROM matterials WHERE parent_id=1

Set up for that case is
$sc_ajax_select_boxes->add_select_box('material_types','id','descr',
'id','','sel1','sel_id_1','');
$sc_ajax_select_boxes->add_select_box('materials','id','descr',
'id','','sel2','sel_id_2','');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', 'parent_id','');


In order to link a third one, then material id value should be used to filter again records on a other table or even the same, depends on data organization.

messageRe: database structure
Posted by: panos (IP Logged)
Date: December 22, 2006 05:00AM

With the new parameter on add_select_box method now data can be hold in one table.

id - parent_id - descr
1 - 0 - Gas
2 - 0 - Solid
3 - 1 - Neon
4 - 1 - Oxyzen
5 - 2 - Rock
6 - 2 - Glass
7 - 2 - Wood

To get root items we need and extra filter on where clause parent_id=0.
This is now added on add_select_box method.

$sc_ajax_select_boxes->add_select_box('lsd_demo_2','id','descr',
'rec_id',2,'sel1','sel_id_1','', 'parent_id=0');

messageCustomazing
Posted by: gcan (IP Logged)
Date: May 26, 2008 11:24AM

Hello,

Great script! Thanks.

I am customazing it for my needs, but can not understand all values:

$sc_ajax_select_boxes->add_select_box('sc_page_types','page_type','type_descr','page_type','','sel1','sel_id_1','');


1) sc_page_types = name of the table
2) page_type = database column
3) type_descr = database column
4) page_type = order by
5) ?????
6) sel1 - ???
7) sel_id_1 - ???
8) ???

Can anyone explain what are last 4 values which I marked with "???".

Thank you very much.

messageRe: database structure
Posted by: panos (IP Logged)
Date: May 27, 2008 03:00AM

Hi,
thanks for your kind words.

I thought that documentation was clear sad smiley

5. is selected value
6. is the select box name <select name="this">
7. is select box id <select name="this" id="id_323">
8. is tag extra attributes like class="box"
and actualy there are 2 more optional parameters
9. extra where = some additional sql you need to add to the where clause
10. select prompt text = the "Please Select" text

more details in [www.salix.gr]

Hope it helped.

messageRe: Customazing
Posted by: gcan (IP Logged)
Date: May 29, 2008 06:25AM

panos, thank you very much.



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum