Generally we create rows, check boxes, buttons, hyperlink statically. But when we want it to create dynamically or when we have to associate it with row fetched from database and we don't know the exact result has to come.
If we want to create fixed number of elements dynamically, obviously we use loop like that
<table>
<%
If we want to create fixed number of elements dynamically, obviously we use loop like that
<table>
<%
int i=0;
while(i<=10)
{
%>
<tr><td>your data</td></tr> //it prints 10 table row
<input type="search" /> // it prints 10 textfield
<input type="submit" value="Search" /> // it prints 10 buttons
..... and so on
<%
i++;
}
%>
</table>
If we get data from database and want these elements to associate with this then
just change the loop
while(rs.next())
{
// put your elements according to you//
}
No comments:
Post a Comment