• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic addition of items to combo inJSP

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am searching for a procedure to add the elements fetch from a database to a combo box in JSP.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most important thing you have to understand with JSP is that JSP is just a way of describing a program to write HTML pages. So if you want to produce a selection list (although, remember that the HTML "select" tag is not quite the same as a Windows "combo box"), the steps are as follows:
  • practice on a regular HTML file until you are happy with the syntax of the HTML "select" tag.
  • copy the "select" code you have tested into your JSP
  • replace the hard-coded "<option>" tags with a loop reading the values from your database results and writing out similar tags to the output stream


  • Does that help?
     
    Shunmu U
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Wonderful ... It worked well ... Thanks a lot for ur help ..
     
    Ranch Hand
    Posts: 862
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    For an easier way to generate HTML elements such as tables, listboxes, drop down listboxes, multi select listboxes and more check out the FormattedDataSet (http://www.fdsapi.com).
    It is as easy as the following coe. Note that the drop down list box code highlights the selected value too.

    The site has a live demo that allows you to type in queries and another that creates standard html elements such as list boxes off of 2 dimensional arrays (another supported datatype, but it would work the same for ResultSets or queries too).
     
    reply
      Bookmark Topic Watch Topic
    • New Topic