Results 1 to 6 of 6
  1. #1
    Alano68 is offline Member
    Join Date
    Jun 2014
    Posts
    2
    Rep Power
    0

    Default Create Cascading Dropdown List Boxes

    Hi,

    I wish to build a JSP interface that uses three drop down lists where the values listed are from a database and each dropdown lists selected value is dependant on the previous one. That is, drop down list one shows a list of data and the selected value filters the select statement for the second drop down list and the value selected in drop down list 2 filters the select statement for the third drop down list.

    The aim is to basically build up a final select statement created from the three drop down list values that will show the results in a grid.

    Can someone provide some guidance for this please? - Newbie to JSP!!!

    Thanks in advance.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default Re: Create Cascading Dropdown List Boxes

    This seems more like a javascript question than a JSP question.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Create Cascading Dropdown List Boxes

    Agreed on the Javascript part, but here it goes anyway: if you're confident, you write a little Ajax subroutine that populates the other dropdowns as a choice is made. If you don't know how to make an Ajax call, just submit the page to whatever generated this page so it can read the value from the first dropdown, populate the second and return the HTML.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: Create Cascading Dropdown List Boxes

    Quote Originally Posted by SurfMan View Post
    Agreed on the Javascript part, but here it goes anyway: if you're confident, you write a little Ajax subroutine that populates the other dropdowns as a choice is made. If you don't know how to make an Ajax call, just submit the page to whatever generated this page so it can read the value from the first dropdown, populate the second and return the HTML.
    Third way that requires no roundtrip to the server: generate a 2D Javascript array with all the possible choices and onchange of the first selection box, update the second selection box by populating it from that javascript lookup table. That's how I used to do it before Ajax was a thing :)

    That is only really an idea if there are only two selection boxes though; as soon as you have more (which is the case here), for the love of god use JQuery and Ajax.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Alano68 is offline Member
    Join Date
    Jun 2014
    Posts
    2
    Rep Power
    0

    Default Re: Create Cascading Dropdown List Boxes

    Quote Originally Posted by SurfMan View Post
    If you don't know how to make an Ajax call, just submit the page to whatever generated this page so it can read the value from the first dropdown, populate the second and return the HTML.
    Thanks to you and others for the response. Okay so Ajax is the way to handle this. Can yourself or any of the others point me to a solid tutorial on this please? Could you elaborate on "just submit the page to whatever generated this page so it can read the value from the first dropdown"

    Thanks again for your patience I am a JSP AND AJAX newbie! (In fact a web newbie all together)

    Alano68

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Create Cascading Dropdown List Boxes

    If you're using Ajax, then you don't have to submit the page, at least, not until the very end.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Replies: 1
    Last Post: 11-29-2012, 01:12 PM
  2. List Boxes
    By zzpprk in forum AWT / Swing
    Replies: 2
    Last Post: 12-15-2009, 09:43 PM
  3. Jtextbox with dropdown list
    By vijay_s in forum AWT / Swing
    Replies: 1
    Last Post: 05-08-2008, 10:17 PM
  4. Jtextbox with dropdown list
    By vijay_s in forum AWT / Swing
    Replies: 3
    Last Post: 05-08-2008, 06:26 AM
  5. Help with dropdown list
    By barney in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 07:17 AM

Tags for this Thread

Posting Permissions

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