Corresponding List Boxes

Results 1 to 4 of 4

Thread: Corresponding List Boxes

  1. #1
    Join Date
    Dec 1969

    Default Corresponding List Boxes

    I have put together three list boxes that are filled by a adodb connection to my database. The first list box is city, two is state, three is zip. I need to set the boxes so that if a person pulls arizona from the state list box the city list box will then only list the cities in Arizona. And then the zip list will correspond with the zip codes for the city. So when the form is submiited I can hope that a correct city state and zip query goes to my database to pull back the right rows from the table. Is it possible if so how is it done?

  2. #2
    Join Date
    Dec 1969

    Default RE: Corresponding List Boxes

    I have the *beginning* of what you want at <BR><BR>(look for the "categories" demo).<BR><BR>This question is asked so frequently that I&#039ve decided I&#039ll try to put up a demo of almost exactly what you want--using *at least* two completely different methods--in the not too distant future. Look for the announcement of it, when I add it to ASPFAQs.<BR><BR>

  3. #3 Guest

    Default RE: Corresponding List Boxes

    Well, I recently implemented something like this in javascript (JS), but I think it is a little flaky, ie it will work in IE5 and maybe IE4, but I don&#039t know about Netscape.<BR><BR>It invloved setting the list boxes as per you page. Then on openning the page I extracted the list of options in each list into arrays. Then when the user selects an item from the first list, all items are removed from the second list and the second list is re-done with items that match the first list. The catch is that the items in the second list (the cities) each have a state code in brackets and the JS extracts the code from the brackets to check that each code matches.<BR><BR>I do not have the code with me and it was too specific to my project for me to post it here. However you should look up DHTML/Document Object Model on the MSDN ( Here is a snippet from MSDN that shows how to add options to a select list:<BR><BR>var oOption = document.createElement("OPTION");<BR>oOption.text= "Apples";<BR>oOption.value="5";<BR>document.all.My List.add(oOption);<BR><BR>If you study this code and learn about JS arrays on the options collection then you should be able to wrk out how to code it. Sorry I can&#039t be more specific.<BR><BR>

  4. #4 Guest

    Default I meant to add a bit more

    What I meant to add to my reply, is that although the client-side JS did work, it created a bit of a delay each time the options had to be recreated.<BR><BR>I think it would have been a lot easier to do if I had forced the form to be submitted after the first list box was changed, thereby creating the second list with correesponding items, and so-forth when the second list is changed. Although this would cause round trips to the server, it would be less likely to fail due to browser idiosyncracies.

Posting Permissions

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