Click to See Complete Forum and Search --> : Populating List boxes
phence
03-07-2003, 12:03 AM
Okay, I have one listbox that is populated from a mysql database using php. Now i need to populate other list boxes that are located on the same page based on the users response to the first or following listboxes. The Number of list boxes has to be determined along the way...
Here is somthing similar to what i need. http://www.csd.toshiba.com/cgi-bin/tais/su/su_sc_modSel.jsp
I tried adapting this script to my site, but i can't figure how to add more list boxes as needed by the users selection..
I have a database of categories, sub categories, categories of sub categories and so on. The first list box shows all the Main Categories. The second will show any sub categories of the selected Main Category. The third will show any categories of the sub categories etc... their has to be basically an infinate number of list boxes avaialible to allow the user the choice for any sub categories.
I hope that was understandable.
How can I do somthing like this?
I would greatly appreciate any help anyone may be able to offer.
Thank You.
cyberade
03-07-2003, 05:53 AM
http://forums.webdeveloper.com/showthread.php?s=&threadid=4799&highlight=dropdown
Is that the sort of thing you're looking for?
phence
03-07-2003, 02:17 PM
well somthing like that, only with list boxes, not drop down menus.. and i can't figure again how to determine the Number of list boxes on the fly..
consider this:
Some Categories may only have one sub category, others may have many.. look Below, above the category/sub category, there are the numbers to which list box the should apear in.
1st > 2nd > 3rd
Cars > Coupe > Ford
Cars > Sports > Chevy
Cars > Classic > Pontiac
1st > 2nd > 3rd > 4th > 5th
Sporting Goods > Equiptment > Fishing > Poles > Ugly Sticks
Sporting Goods > Equiptment > Firearms > Rifles > Remmington
If a Category has 2 trailoring categories, the page should display in another list box the 2 sub categories, if a user selects a sub category and the sub category has categories of it's own then another listbox should be shown, showing the categories of the sub categories and so on...
If you look above where i give the structure of categories. Cars and Sporting goods would be displayed under the Main category list box. If you choose 'Cars', then a second list box should apear and display the types of cars (Coupe, Sports, Classic, hatchback, etc...). If you then choose 'Sports' another list box would apear displaying a list of all the makes of cars (Chevy, Pontiac, Ford, GMC...etc) and so on. Get it???
Does that clear it up at all? This site here is similar to what i need. http://www.csd.toshiba.com/cgi-bin/...u_sc_modSel.jsp
But just a little more advanced, with determining how many listboxes need to be shown and displaying them.
phence
03-08-2003, 01:00 AM
here is another example and sorta a tutorial for the core part of the script. Only I am using php to get the data, and i need to be able to use more than three list boxes.
http://www.atgconsulting.com/triplelist.asp
Is there a way that a funtion could be implemented on a script like this that can determine the number of list boxes bassed on the users selections and display the listboxes as needed?
If anyone can help, I would greatly appreciate it!
Thank You
EDIT :
Another Example:
http://www.siteexperts.com/tips/elements/ts20/lookup.asp
Vladdy
03-08-2003, 08:33 AM
Maybe you need to rethink your interface. Cramping 5 listboxes into one page may become too disorienting. The user works with a given category at a time. My solution would be to have a single list for the current category and arrange the current selection in a tree-like manner above it for example when the user starts he/she is presented with the list of root categories (in a list box) with a title
Product Categories
__________
|cars
|sporting equipment
|toys
when a user selects a category, the list box is populated with products from this category. The root title becomes a link that allows to return to display all categories:
Product Categories
--Cars Makes
________________
| Acura
| Ford
| Subaru
So for the next step, when user selects a make:
Product Categories
--Cars
----Subaru Models
___________________
| Legacy
| Forester
| WRX
If you are ok with relying on javascript, you can implement background server polls so that the transitions are made without reloading the whole page.
phence
03-08-2003, 10:34 AM
Well that is pretty much the same idea i am using, is it not?
I am using a tree like structure for my categories.
That is how i manage categories/subcategories.
See each List Box is going to be populated using PHP and a Mysql Database, but not all Root Categories have the same number of Sub Categories; Most Sub Categories have Sub Categories of thier own.
EX1:
Cars > Hatchback > Ford > Model > Taurus
Cars is the Root Category, Hatchback is a sub category of Cars, Ford is a sub category of Hatchback, Models is a sub category of Ford, Taurus is a sub category of Models.
EX2: Toys > Toddlers
Toys is the Root Category, Toddlers is a Sub Category.
Now, In EX1, There would be a Total of 4 List Boxes needed.
One displaying the list of Root Categories, One to display the Sub categories of the Root Category, Another One Diplaying the Categories under the Sub categories, and Another displaying a list of Categories under Those Sub Categories.
In EX2, There would be 2 list boxes. One displaying the Root Categories and another Diplaying the Sub Categories. Since there are not other Categories of Sub Categories, There is nothing else to break down it's the end of the tree.
whoa...
Vladdy
03-08-2003, 10:46 AM
... In interface concept I gave, all you need is one listbox regardless of number of subcategories. What varies is the "path" to the currently displayed list.
phence
03-08-2003, 10:55 AM
hmmm... do you have any exapmles... like code wise?
Vladdy
03-08-2003, 02:46 PM
I do not have anything for cut-n-pasting but I developed a few interactive pages and what you are trying to do is nothing special. The actual implementation would depend on your requirements. It can be done pure server side for wide browser support or if you want to make it real slick it can use background server polls and dynamic content manipulation with javascript. The server side code would depend on your database organization as well.
phence
03-09-2003, 11:19 AM
well, so what do i have to do now to get what i want done?
I already have a the backend and php created. I just need somthing so the user can make their selections, I think that listboxes are the best method. i'm still not 100% sure what your alternative is. If you could help me out i'd really appreciate it!
thanks
sean