dcsimg
www.webdeveloper.com
Results 1 to 8 of 8

Thread: how use a listbox for select items beetween 3 lists?

  1. #1
    Join Date
    Oct 2008
    Posts
    72

    how use a listbox for select items beetween 3 lists?

    hi,
    i want select 3 categories using 3 listboxes
    like this picture show

    how can i do that?


    thanks for your help
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    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).

  3. #3
    Join Date
    Oct 2008
    Posts
    72
    hi,
    yes is thats what i want i have searched for examples but without sucess
    can you point some samples

    thanks a lot for your help

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    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. 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.

  5. #5
    Join Date
    Oct 2008
    Posts
    72
    i using php and the list info is stored in a mysql db
    thanks

  6. #6
    Join Date
    Nov 2008
    Location
    Akron, OH
    Posts
    233
    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/web...item.php/91311
    Last edited by javawebdog; 11-30-2008 at 02:32 PM. Reason: add another resource

  7. #7
    Join Date
    Oct 2008
    Posts
    72
    hi the samples works fine but i looking for a listbox not a combo list the way is the same? thanks

  8. #8
    Join Date
    Nov 2008
    Location
    Akron, OH
    Posts
    233
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles