我使用jsp和java从mysql db中获取并显示数据作为html表现在我想要的是当用户点击特定行时,如果我的表有这个数据,那么该行中的数据应该填充在3个不同的标签示例中
姓名 地点 手机号码
a abc 123
b def 234
c ghi 345
(上表取自mysql db)
如果用户单击第 3 行,则姓名地点和手机号码等数据应显示在 3 个不同的标签中,如下所示
Name: c
Place: ghi
Mobile: 345
提前致谢
在我曾经在每行右侧有一个带有“名称”的按钮之前(如果它是一行 c,那么按钮有 c),所以我使用 CSS 用图片装饰了按钮。
这是我使用的代码
<form action="Options2" method="post">
<table id="sorter" class="sortable" id="example" class="pretty">
<tr>
<th>Book Id</th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Status</th>
<th>Owner</th>
<th>Borrow Date</th>
<th>Return Date</th>
<th>Requested By</th>
<th>Actions</th>
</tr>
<%
ArrayList rs=(ArrayList)request.getAttribute("news");
ListIterator itr=rs.listIterator();
int i=1;
while( itr.hasNext()){
%>
<tr>
<td><%=itr.next()%></td>
<% int Id = itr.nextIndex(); %>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<% int Id2 = itr.nextIndex(); %>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<td><%=itr.next()%></td>
<%
String Bname=rs.get(Id).toString();
System.out.println(Bname);
String Stat=rs.get(Id2).toString();
System.out.println(Stat);
if(!Stat.equals("Not Availible"))
{
%>
<td>
<input class="buttonir" type="Submit" name="X" value="<%=Bname %>"></td>
</tr>
<%
}
}
%>
</table>
</form>