jsp页面中的动态内容表
我对jsp页面有问题(我是新手)。 在jsp页面中,我编写了一个从数据库读取的表。 我在这里写下页面的代码:jsp页面中的动态内容表,jsp,Jsp,我对jsp页面有问题(我是新手)。 在jsp页面中,我编写了一个从数据库读取的表。 我在这里写下页面的代码: <%@page import="java.sql.SQLException"%> <%@page import="java.lang.String"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.Statement"%> <%@page import
<%@page import="java.sql.SQLException"%>
<%@page import="java.lang.String"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.Date "%>
<%@page import="jord.ConnectionManager "%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String sql= "select numelencotrasm,dtelencotrasm \n"+
"from fimand \n"+
"where eser=2012 \n"+
"group by numelencotrasm,dtelencotrasm \n"+
"order by numelencotrasm";
ConnectionManager manager = new ConnectionManager();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
conn = manager.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}catch(SQLException ex){
rs.close();
conn.close();
rs=null;
conn=null;
response.sendRedirect("../index.jsp");
}
%>
<form id="tabella1" name="tabella1">
<input name="numelencotrasm" type="hidden" value=""/>
<input name="dtelencotrasm" type="hidden" value=""/>
<table width="275px" cellspacing="0" cellpadding="1" border="1">
<tr>
<td class="TabellaTitolo" width="50%">
Numero Distinta
</td>
<td class="TabellaTitolo" width="50%">
Data Distinta
</td>
<td class="TabellaTitolo" width="50%">
#
</td>
</tr>
<%
try{
while(rs.next()){
%>
<tr>
<td>
<input type="text" value="<% out.print(rs.getInt(1)); %>"/>
</td>
<td>
<input type="text" value="<% out.print(rs.getDate(2)); %>"/>
</td>
<td>
<a href="#" onclick="javascript:setValue('<% out.print(rs.getInt(1)); %>','<% out.print(rs.getDate(2));%>');">
Click-me
</a>
</td>
</tr>
<%
}
}catch(Exception e){
response.sendRedirect("../index.jsp");
}
%>
</table>
</form>
<script language="Javascript">
function setValue(num, dt){
document.tabella1.numelencotrasm.value=num;
document.tabella1.dtelencotrasm.value=dt;
alert(document.tabella1.numelencotrasm.value); //test
alert(document.tabella1.dtelencotrasm.value);//test
}
</script>
数字差
数据区
#
函数设置值(num,dt){
document.tabella1.numelencotrasm.value=num;
document.tabella1.dtelenctrasm.value=dt;
警报(document.tabella1.numelencotrasm.value);//测试
警报(document.tabella1.dtelencotrasm.value);//测试
}
嗯。。现在我想创建一个新的html表,单击“#”行从数据库中读取传递值的数据选定行的名称
我为基础英语道歉!:/ 您需要对上述jsp代码进行以下更改:
action=“targetPage.jsp”
iframe
。信息技术
应类似于target=“nameofiframe”
iframe
。其应类似于
setValue
函数中,编写提交表单的说明不建议让jsp中与连接相关的代码改用servlet,但如果我提交表单,将重新加载页面。我想在单击表1时显示一个包含日期表2的iframe。有可能吗?谢谢!你的回答很有帮助。这是我关于StackOverflow的第一个问题,我不知道是否应该做些什么来结束这个问题。@user1418910不需要结束。但如果你有足够的声誉价值,也请投票支持我的答案。