Click to See Complete Forum and Search --> : how use a listbox for select items beetween 3 lists?


jasonx22
11-28-2008, 03:05 PM
hi,
i want select 3 categories using 3 listboxes
like this picture show

how can i do that?


thanks for your help :)

Mindzai
11-28-2008, 04:21 PM
I'm assuming you mean each <select> would be updated based on the value selected in the one before. In this case it is usually done these days using AJAX, the server side component of which is usually something like a PHP script which returns the values corresponding to the previous selection. You can do this relatively easily using jQuery or another framework with AJAX functions (or youcould write your own but in all honestly there's not much point when it's been done for you already).

jasonx22
11-28-2008, 05:12 PM
hi,
yes is thats what i want i have searched for examples but without sucess
can you point some samples:confused:

thanks a lot for your help

Mindzai
11-28-2008, 05:33 PM
Well I don't know which scripting language you intend to use on your server, or where the information is coming from to populate the list boxes, so it's hard to give you any pointers on that side of things, but a good place to start would be the jQuery AJAX documentation (http://docs.jquery.com/Ajax). I would recommend jQuery for handling the client side of your program because it has built in functionality for everything you will need to do.

jasonx22
11-28-2008, 05:46 PM
i using php and the list info is stored in a mysql db
thanks

javawebdog
11-30-2008, 01:25 PM
Let's assume (just for fun) that AJAX is not an option for you ;-)
For the first select set an onchange event that calls a javascript function that builds/populates the second select, which in turn calls another javascript function that in turn builds/populates the third. The data for each could be a set of arrays. Wholly client-side and admittedly very old school.

Saw an example on a German domain site: http://www.fh54.de/js/cascadingselects/
Another at http://webdeveloper.earthweb.com/webjs/jsnavigation/item.php/91311

jasonx22
11-30-2008, 03:09 PM
hi the samples works fine but i looking for a listbox not a combo list the way is the same? thanks

javawebdog
11-30-2008, 04:18 PM
Same problem. The difference between a combo box and list box is the size attribute.
Typically combo are <select size="1"> if no size is supplied "1" is the default. A list box is just a select where the size=>the number of expected items.

That said the since they both use the same html elements they have the same behaviors and constraints.