• 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

dynamically create select box

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear friends
recently i was developing one application in which i was required to dynamically create a given number of select box depending on number selected by the user from another select box in runtime and the option of the former select box(ie select box's created dynamically ) have to be be retrive from the database which is sql.
can anybody help me solving this problem?

manash
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manas manas:
dear friends
recently i was developing one application in which i was required to dynamically create a given number of select box depending on number selected by the user from another select box in runtime and the option of the former select box(ie select box's created dynamically ) have to be be retrive from the database which is sql.
can anybody help me solving this problem?

manash



hmm..i'll give it a try.. (i'm assuming that you are writing a jsp )
submit the form on the onchange event of the first select box (containing number of select boxes to be displayed)
get the selected value of first select box by request.getParameter()
use a while loop with this value and generate the html code to create the select boxes

something like this...

(pls take care of runtime exceptions , like NPE)
<% int noOfSelBoxes = new Integer(request.getParameter("selectBox1")).intValue();
%>
// your other html code

<% while(noOfSelBoxes >0) { %>
<tr>
// here goes your select box code
</tr>
<% noOfSelBoxes--;
} %>

Hope this helps.

Regards,
Abhimanyu
[ November 18, 2004: Message edited by: Abhimanyu Kumar ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you were to take care to write it out in proper English maybe you would understand the problem better.
It would certainly lead to people here understanding it better and maybe even spend some time to help you rather than think what a lazy careless person it is who doesn't even make the effort to word his questions in proper English.

What you want is actually quite easy and has been done many times before. I'm sure you can figure out how to do it if you just think about it a bit, which you could do while waiting for someone to write your code for you which is unlikely to happen...
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic