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
messageLinking selecte boxes
Posted by: MicroHellas (IP Logged)
Date: February 21, 2009 05:34AM

Hello Panos,

I've a problem understanding the values for: link_select_boxes

Here is my values:
$sc_ajax_select_boxes->add_select_box(categories', 'id', 'name', 'displayorder', '', 'sel1', 'sel_id_1', '', '', 'Select');
$sc_ajax_select_boxes->add_select_box(subcategories', 'id', 'name', 'displayorder', '', 'sel2', 'sel_id_2', '', '', 'Select');
$sc_ajax_select_boxes->add_select_box('thirdcategories', 'id', 'name', 'displayorder', '', 'sel3', 'sel_id_3', '', '', 'Select');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', '???????','???????');
$sc_ajax_select_boxes->link_select_boxes('sel2','sel3', '???????','???????');

What I need to enter instead of ????? when my database schema is:

CREATE TABLE IF NOT EXISTS categories (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`displayorder` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `displayorder` (`displayorder`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS subcategories (
`id` int(11) NOT NULL auto_increment,
`categoryid` int(11) default NULL,
`name` varchar(50) default NULL,
`displayorder` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `displayorder` (`displayorder`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS thirdcategories (
`id` int(11) NOT NULL auto_increment,
`subcategoryid` int(11) default NULL,
`name` varchar(50) default NULL,
`displayorder` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `displayorder` (`displayorder`)
) ENGINE=MyISAM;

Eyharistw
Maria

messageRe: Linking selecte boxes
Posted by: panos (IP Logged)
Date: February 22, 2009 02:33PM

Hi Maria,

link_select_boxes method tells how the 2 select boxes are linked smiling smiley
3rd parameter is used in the where clause when records are retrieved for second select box.
As documentation says:

Syntax: link_select_boxes(parent_box_name, child_box_name,
link_field_name, selected_value)

SELECT key_field_name, description_field_name
FROM db_table_name
WHERE link_field_name=selected_value
[ORDER BY order_field_name]

So for your database sould be in the first link categoryId and for second link subcategoryid.

Documentation helps even me grinning smiley

Best regards
and i very happy to have a post from greece winking smiley
Panos

messageRe: Linking selecte boxes
Posted by: MicroHellas (IP Logged)
Date: February 23, 2009 12:48AM

Hello Panos,

I tried to find documentation, but the only that I found was about form elements, that's why I went througout reading all posts here to solve me problem.

Unfortunatelly, still no luck to make it working. A copy of the full code is below:

<body>
<script src="prototype.js" type="text/javascript"></script>
<h2><a href="http://www.salix.gr/ajax_linked_selectboxes">Salix.gr - Ajax Linked Select boxes Demo</a></h2>
<?php

include("top_script.php");
include("sc_classes.php");

$sc_ajax_select_boxes = new sc_ajax_select_boxes();
$sc_ajax_select_boxes->xml_encoding='ISO-8859-1'; // use this property if you need other encoding than latin
$sc_ajax_select_boxes->add_select_box('vb_travel_categories', 'id', 'name', 'displayorder', '', 'sel1', 'sel_id_1', '', '', 'PSelect');
$sc_ajax_select_boxes->add_select_box('vb_travel_subcategories', 'id', 'name', 'displayorder', '', 'sel2', 'sel_id_2', '', '', 'PSelect');
$sc_ajax_select_boxes->add_select_box('vb_travel_thirdcategories', 'id', 'name', 'displayorder', '', 'sel3', 'sel_id_3', '', '', 'PSelect');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', 'categoryid','');
$sc_ajax_select_boxes->link_select_boxes('sel2','sel3', 'subcategoryid','');
$sc_ajax_select_boxes->place_jscripts();
$sc_ajax_select_boxes->show_select_box('sel1');
$sc_ajax_select_boxes->show_select_box('sel2');
$sc_ajax_select_boxes->show_select_box('sel3');
?>
<div id="dump_area"></div>
</body>

and the link to check it, is: [www.vbtraveladvisor.com]

Thank you
Maria

messageRe: Linking selecte boxes
Posted by: panos (IP Logged)
Date: February 25, 2009 02:48AM

Hi Maria,
something is wrong with your installation of the script and not class parameters.
Try the link [www.vbtraveladvisor.com]
this should return xml document with avail options but it returns some php errors.
Pls check those first.



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