Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: dynamically fetch values from database and display in combo box in jsp

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default dynamically fetch values from database and display in combo box in jsp

    I am making a form in jsp where i have to filter 4 combo boxes one after the other .. the values of the combo box have to be fetched from the database dynamically..
    in table there are 5 fields:-
    id category subcategory brand price
    1 garments jacket adidas 4000
    2 garments shirt peter England 1000
    3 sports bat BDM 800

    my form contains combo boxes namely:
    category:
    subcategory:
    brand:
    price:

    firstly, category should display only those values in list(on front end) that are present in database.[I have done this with sql query and resultset](e.g- garments,sports)
    Now on selecting the category(e.g- garments) only the respective subcategory should be displayed i.e next combo box should contain only- jacket, shirt.
    similarly other lists should be filtered..
    Please tell me statements should be used.


  2. #2
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    With the current table structure you can't do it. You need to normalize your table to be able to fetch data as you wish.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    Quote Originally Posted by dineshj83 View Post
    With the current table structure you can't do it. You need to normalize your table to be able to fetch data as you wish.
    please tell me how to normalize the table

  4. #4
    Member
    Join Date
    Nov 2013
    Location
    Bangalore, India
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    Please read topics on Database normalization and apply it.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    I'm not as smart on database structure as dineshj83, but it occurs to me that your question may be as much about writing the code to react to the user's choice in the combo boxes as it is to program the database query. For that, you could start with simple String arrays and develop your combo box logic. Once that is done, you could transition from the String arrays to the database queries. If you'd like more help with the combo box logic part of the question, let me know.

  6. #6
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    Quote Originally Posted by GregBrannon View Post
    I'm not as smart on database structure as dineshj83, but it occurs to me that your question may be as much about writing the code to react to the user's choice in the combo boxes as it is to program the database query. For that, you could start with simple String arrays and develop your combo box logic. Once that is done, you could transition from the String arrays to the database queries. If you'd like more help with the combo box logic part of the question, let me know.
    thanks, I've done with arrays and javascript ..but this is static coz I am manually entering the values in combobox.. But here I have to fetch the values from the database in the combobox.. this is related to multiple resultsets.

  7. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    Okay, the over to dineshj83 and the magic of normalized databases. Good luck!

  8. #8
    Junior Member
    Join Date
    Nov 2013
    Posts
    5
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: dynamically fetch values from database and display in combo box in jsp

    Quote Originally Posted by GregBrannon View Post
    Okay, the over to dineshj83 and the magic of normalized databases. Good luck!
    thank you

Similar Threads

  1. Display database values into JTables
    By tommyacton in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 13th, 2013, 02:54 PM
  2. Replies: 2
    Last Post: March 12th, 2013, 06:16 AM
  3. comparison of data from front-end jsp page to database values
    By yashwanthguru in forum JDBC & Databases
    Replies: 0
    Last Post: March 1st, 2013, 12:37 PM
  4. Making an input dialog box appear after closing a combo box
    By Shenaniganizer in forum What's Wrong With My Code?
    Replies: 14
    Last Post: November 11th, 2012, 06:22 PM
  5. Loading contents of a Database into a Combo box
    By tyolu in forum JDBC & Databases
    Replies: 3
    Last Post: June 22nd, 2009, 08:14 AM