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 ]