• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Dependent/chain comboboxes on same jsp page

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii.
I am making a web interface , which requires selection of various values from dependent combo boxes. Currently i am doing this by displaying values,which are dependent to the values previously selected, on different pages in tables with checkboxes to select. but this is quite lengthy interface. i want to make a web interface which should have all the values on the same page in various dependent comboboxes, so that if i select a values from one combobox, the other dependent values to the selected record should be displayed in the next combobox by retrieving the values from the Mysql database ans so on.
i know this has to be done with the help of Java Script. but as i am a new to the Java Script , so can't figure it out . Please help me with the brief sample code to retrieve values from database and showing them in the next dependent combobox.
Thanks.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of things:
  • Read HtmlHasNoComboBox -- proper terminiology is important
  • Also, you'll need to do this with JavaScript, so I've moved this to the HTML forum

  • Most people will use Ajax to fetch the values as they are needed -- eliminating the need to preload all the data possibilities (which can be extensive) -- but if you want to preload the values, you'll need to store them in JavaScript constructs for use when the event handlers for the dropdowns fire off.
     
    Vazzdoin Rocko
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for replying. Well,I've also seen on net many people saying that i should sort out this problem with the help of AJAX.So can you post some sample code,or tutorial, dealing with such problem of multiple dependent comboboxes on a single JSP page, and retrieving all the values selected in the end or on submit.
    Thanks
     
    Bear Bibeault
    Marshal
    Posts: 67418
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ajax is a lot easier if you use a library such as jQuery or Dojo. With jQuery, it's just a few lines of code.
     
    Vazzdoin Rocko
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Really .. is that so simple . M excited, kindly post some relevant sample link
     
    Bear Bibeault
    Marshal
    Posts: 67418
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A simple jQuery example. Let's say that the URL /fetchOptions returns an HTML fragment containing the <option> elements to be loaded into a select element with the id of mySelect.

    The following statement loads the select element with the options:


    That's a lot easier than the page-full of code that Ajax would normally entail.

    You can read up on jQuery at http://docs.jquery.com/Main_Page
     
    Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic