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
messageI have a problem in Linked Select Boxes.
Posted by: cibimdu (IP Logged)
Date: September 21, 2007 02:52AM

Sir,
I am trying to use the linked select box in my application. i have 3 tables to be linked. 1. Department, product, category.

i configured selectboxes as per example 1. It works fine except for a particular department name. the department name has space in it ie "Quality Control". The Items are not displayed for this department alone. How to solve this issue. Even Please select option is also not displayed for this department.

2. The product "A" Belongs to Department "D" falls under category "C". I need "A" Value.
"A","D","C" are 3 different tables. Where "A" has relationship with "D" & "C". But "D" & "C" has no relationship. I am able to link "A" & "D", get "A" value comes under "D" department. But the 3rd condition, i don't know how to give it.

Please help me.
regards
rajkumar

messageRe: I have a problem in Linked Select Boxes.
Posted by: panos (IP Logged)
Date: September 22, 2007 04:32PM

Hi Rajkumar,

As for problem 1, department with space in it, I dont think that the problem is
the space in description in example all descriptions have spaces in them. So
the problem must be else where.

Now, let me see if i got your case right.
Department table is some thing like:
Dept_id | Description

Categories table is like:
Category_id | Description

and Products table is like
Product_id | Description | Dept_id | Category_id

and you want to have 3 select boxes like:

Departments
Categories (Categories for selected department)
Products (products for selected category)

Right?

In this case I am afraid that you have to make some
changes in order to use Linked Select Boxes,
or you have to code your own tailored ajax boxes.

In case you can modify a bit your table stucture, you should add Dept_id to Categories
table so you can have a "strait" relation Departments->Categories.

Categories table should be like:
Category_id | Description | Dept_id

Hope this helped.

Regards
Panos

messageRe: I have a problem in Linked Select Boxes.
Posted by: cibimdu (IP Logged)
Date: September 23, 2007 11:04PM

Dear Panos,

We have identified the cause for the problem 1. The word 'Control' in the Department "Quality Control" is causing the problem. Suppose if we change the department name into "Quality Contr" in both product & department table, we could get the product listing for the department "Quality Contr". if we add 'ol' ie keep department as 'Quality Control', the ajax returns no value.

I think the error happens with the string contains 'control' Any fix is available with your programme to handle the string 'Quality Control'..?

Please reply

regards
rajkumar

messageRe: I have a problem in Linked Select Boxes.
Posted by: panos (IP Logged)
Date: September 24, 2007 02:47AM

A detail to help me locate the problem, are you using strings as keys?

I mean Departments table is like

Department_id (varchar)
Description (varchar)

messageRe: I have a problem in Linked Select Boxes.
Posted by: panos (IP Logged)
Date: September 24, 2007 02:53AM

Can you please mail me your departments table?
I tested having item id and description 'Quality Control' and it worked fine.
Only i had to make example table fields bigger cause they where 10 chars and
'Quality Control' wouldnt fit.

Regards
Panos

messageRe: I have a problem in Linked Select Boxes.
Posted by: cibimdu (IP Logged)
Date: September 24, 2007 12:19PM

Dear Panos,
here below the script i tried for linking 2 tables. The table structures & data i sent as attachment to your mail id from cibimdu@yahoo.com.

I had just altered your example script and tried as follows.

<?php

include("top_script.php");
include("sc_classes.php");
$sc_ajax_select_boxes = new sc_ajax_select_boxes();
$sc_ajax_select_boxes->add_select_box('department',"dname",'dname','','','sel1','sel_id_1','');
$sc_ajax_select_boxes->add_select_box('product','name','name','','st21','sel2','sel_id_2','','');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', "department",'t2');
$sc_ajax_select_boxes->place_jscripts();
$sc_ajax_select_boxes->show_select_box('sel1');
$sc_ajax_select_boxes->show_select_box('sel2');
?>

messageRe: I have a problem in Linked Select Boxes.
Posted by: panos (IP Logged)
Date: September 25, 2007 07:11AM

ok, your data helped to figure out the problems.

First the correct script is:

$sc_ajax_select_boxes = new sc_ajax_select_boxes();
$sc_ajax_select_boxes->add_select_box('department','dname','dname','','','sel1','sel_id_1','');
$sc_ajax_select_boxes->add_select_box('product','name','name','','','sel2','sel_id_2','','');
$sc_ajax_select_boxes->link_select_boxes('sel1','sel2', 'department','');
$sc_ajax_select_boxes->place_jscripts();
$sc_ajax_select_boxes->show_select_box('sel1');
$sc_ajax_select_boxes->show_select_box('sel2');

you forgot to remove a default value 't1'.

The second problem was your data... you are using name fields for select boxes keys and
some of them had the & character in them which causes problems to xml exchange.

Please download the version of code i uploaded today and there want be that problem any more
but be aware that in $_POST selected keys are urlencoded. banks to %20 and so on.

Thanks for causing that trouble smiling smiley

panos



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