Hi I am using servlets to connect to a database and display it in the form of HTML table. I need to assign a radio button to each row, keeping in mind that this a big table containing around 100 rows. THe radio button should be a column before "Name". How can I assign a radio button to each row without doing 100 times like <input type=radio name="id" value="1"> for each row because I am using result set to display the table.
Any help would be greatly appreciated Thanks
Robert Brunner
Ranch Hand
Joined: Jul 18, 2001
Posts: 49
posted
0
Try doing it in JSP. You can set up a loop to itereate over the result set and print out the html as you want.
Chak Terlapu
Ranch Hand
Joined: Oct 20, 2000
Posts: 32
posted
0
Hi, I have never used JSP before. Could you tell me where I can find related information so that I could get started on it. Thanks for your help Chak
Samuel Clemens
Greenhorn
Joined: Aug 13, 2001
Posts: 4
posted
0
If you want to continue using a servlet, just put that line of code for the button into your while loop. If you need unique names for each, just use a counter and have the counter value appear as part of the button name, and then increment the counter at the end of each loop iteration. SC
Samuel Clemens
Greenhorn
Joined: Aug 13, 2001
Posts: 4
posted
0
Something like the following might be good! int counter = 1 while(rs.next()){ out.println("<input type=radio name='id'" + counter + " value='1'>"); out.println("<TR>"); out.println("<TD>" + rs.getString("NAME") + "</TD>"); out.println("<TD>" + rs.getString("PHONE") + "</TD>"); out.println("<TD>" + rs.getString("ADDRESS") + "</TD>"); out.println("<TD>" + rs.getString("ADDRESS") + "</TD>"); out.println("</TR>"); counter++; }
Chak Terlapu
Ranch Hand
Joined: Oct 20, 2000
Posts: 32
posted
0
Hi, Thanks for the help, but isn't it the value that should be changing and the name same for all the radio butons . When we do request.getParameter(id) in another servlet then I think we will get the value of the radio button according to which the row info is obtained. I am new to this. Please correct me if it is wrong assumption.
Thanks Chak Something like the following might be good!
Samuel Clemens
Greenhorn
Joined: Aug 13, 2001
Posts: 4
posted
0
Yes, possibly. I haven't been using that stuff lately. But as long as you see my general direction, the rest should follow. Good luck.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.