我是jsp初学者,我想实现一个页面请多帮忙!!

T2 2004-08-02 09:57:56
我想做一个查询列表和详细资料编辑的页面如下:
name tel address
--------------------------------------
123123 12321321 123213
456456 456456 456546
asdsad dwqre ererer
-----------------------------------
name:xxxx tel:xxxx address:xxxx
保存 删除
以上是一个页面
当点击列表其中一条就在下面的明细显示详细资料然后可以编辑。
现在我已经完成了查询列表,可不知道如何做点击其中一条然后显示明细
...全文
348 25 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
softtao 2004-08-03
  • 打赏
  • 举报
回复
各位都是热心肠的人啊!~~~
programdolt 2004-08-03
  • 打赏
  • 举报
回复
友情up
greenfly 2004-08-02
  • 打赏
  • 举报
回复
你参考一下,自己改动一些.
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
Connection con = DriverManager.getConnection("jdbc:odbc:test"); //建立数据库链接
Statement stmt = con.createStatement(); //建立Statement对象
ResultSet rs; //建立ResultSet(结果集)对象
//String mcustomerid=request.getParameter("customerid");
rs = stmt.executeQuery("SELECT * FROM customers where customerid='& mcustomerid &' "); //执行SQL语句
%>
//利用while循环将数据表中的记录列出
<% //String mcustomerid="";

while (rs.next())
{
String mcustomerid=rs.getString("customerid");
String mname=rs.getString("name");
String maddress=rs.getString("address");
String mphone=rs.getString("phone");
String mfax=rs.getString("fax");
String memail=rs.getString("email");
String mwebaddress=rs.getString("webaddress");
//out.println(mname);


%>
<form method="Post" name="RegForm" action="update2.jsp">
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="10"><img src="../../Images/iTFrameHead1.jpg" WIDTH="10" HEIGHT="22"></td>
<td width="100%" height="22" background="../../Images/iTFrameHead2.jpg"><font color="white">发文信息查看</font></td>
<td width="9"><img src="../../Images/iTFrameHead3.jpg" WIDTH="9" HEIGHT="22"></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan="3">
<table border="0" width="100%" class="PuFrame">
<tr><td height="18"></td></tr>
<tr>
<td nowrap align="right" width="25%" height="25">顾客号:</td>
<td nowrap><input type="text" maxlength="100" name="customerid" value="<%= mcustomerid %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">姓名:</td>
<td nowrap><input type="text" maxlength="100" name="name" value="<%= mname %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">地址:</td>
<td nowrap><input type="text" maxlength="100" name="address" value="<%= maddress %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">电话:</td>
<td nowrap><input type="text" maxlength="100" name="phone" value="<%= mphone %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">传真:</td>
<td nowrap><input type="text" maxlength="100" name="fax" value="<%= mfax %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">邮箱:</td>
<td nowrap><input type="text" maxlength="100" name="email" value="<%= memail %>" size="50"></td>
</tr>
<tr>
<td nowrap align="right" width="25%" height="25">网站:</td>
<td nowrap><input type="text" maxlength="100" name="webaddress" value="<%= rs.getString("webaddress") %>" size="50"></td>
</tr>
<tr><td height="20"></td></tr>
</table>
</td>
</tr>
<tr><td height="18"></td></tr>
<tr>
<td colspan="5">
<input type="button" name="Opt" class="btnButton" value="修 改" onclick="RegForm.OptCmd.value='EDIT';if (Check(RegForm)) RegForm.submit()" style="{cursor:hand}">
<input type="button" value="返 回" class="btnButton" onclick="JavaScript:history.back()" id="button1" name="button1" style="{cursor:hand}">
</td>
</tr>
</table>
</form>
<%
}
rs.close(); //关闭ResultSet对象
stmt.close(); //关闭Statement对象
con.close(); //关闭Connection对象
%>

BillyW 2004-08-02
  • 打赏
  • 举报
回复
你这个问题在javascript论坛里找就可以了。
T2 2004-08-02
  • 打赏
  • 举报
回复
up
T2 2004-08-02
  • 打赏
  • 举报
回复
急,快救火
T2 2004-08-02
  • 打赏
  • 举报
回复
to ally810724(尘埃):
你写的我看不太懂,你是用了struts吗?这个我没学过,我这里没有做javabean,也不用,还有没有其他解决办法啊?谢谢了
zhuguiqiu 2004-08-02
  • 打赏
  • 举报
回复
<a href="本页.jsp?name=xxxx&tel=xxxx&address=xxxx">123123</a>
接受到值进行处理
javacsdner 2004-08-02
  • 打赏
  • 举报
回复
UP
ally810724 2004-08-02
  • 打赏
  • 举报
回复
我觉得你可以在显示每行的时候,多加一列---为“显示详细”的button按钮

这个jsp文件供你参考
[注:这是一个显示图书详细信息的,我觉得和你提出的问题类似,希望能对你有帮助]

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page errorPage="showBooks_error.jsp" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><head>
<title>
showBooks
</title>
</head>

<html:errors/>

<html:form action="/queryBooks.do" method="POST" name="queryBookForm" type="team.QueryBookForm">


<jsp:useBean id="bookInfoBean" scope="session" class="team.BookInfoBean" />
<c:set var="book" value="${bookInfoBean.book}"/>
<table align="center" bgcolor="#BB9FF4" border="0" cellspacing="2" cellpadding="2">
<td>书名:</td>
<td><html:text property="name"/></td>
<td>作者:</td>
<td><html:text property="author"/></td>
<td>出版社:</td>
<td><html:text property="press"/></td>
<td>种类:</td>
<td><html:text property="kind"/></td>
</table>
<p>
<input type="submit" name="Submit" value="查询">
</p>
</html:form>

<p><a href="staffwork/addBook.jsp">添加书</a>
</p>

<table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="5">
<tr>
<td width="62" bgcolor="#BB9FF4">ISBN</td>
<td width="57" bgcolor="#BB9FF4">书名</td>
<td width="57" bgcolor="#BB9FF4">作者</td>
<td width="57" bgcolor="#BB9FF4">出版社</td>
<td width="57" bgcolor="#BB9FF4">类别</td>
<td width="57" bgcolor="#BB9FF4">价格</td>
<td width="57" bgcolor="#BB9FF4">折扣</td>
<td width="57" bgcolor="#BB9FF4">库存</td>
<td width="66" bgcolor="#BB9FF4">详细信息</td>
<td width="48" bgcolor="#BB9FF4">修改</td>
<td width="61" bgcolor="#BB9FF4">删除</td>
</tr>

<logic:iterate id="book" name="book">
<tr bgcolor="#fff88">
<td bgcolor="#EEC1ED">
<bean:write name="book" property="isbn" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="name" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="author" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="press" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="kind" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="price" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="discount" /></td>
<td bgcolor="#EEC1ED">
<bean:write name="book" property="store" /></td>
<td bgcolor="#EEC1ED"><html:link page="/detailBook.do" paramId="isbn" paramName="book" paramProperty="isbn">详细信息</html:link></td>
<td bgcolor="#EEC1ED"><html:link page="/readyUpdateBook.do" paramId="isbn" paramName="book" paramProperty="isbn">修改</html:link></td>
<td bgcolor="#EEC1ED"><html:link page="/delBook.do" paramId="isbn" paramName="book" paramProperty="isbn">删除</html:link> </td>
</tr>
</logic:iterate>
</table>

</html:html>
T2 2004-08-02
  • 打赏
  • 举报
回复
我的所有操作都是一个页面怎么做?
alaal 2004-08-02
  • 打赏
  • 举报
回复
每一条记录都有自己的id,在提交个处理页面的时候用xxx.jsp?id=xxx的方法提交过去

处理页面根据id进行数据库操作
T2 2004-08-02
  • 打赏
  • 举报
回复
最好能给出代码
T2 2004-08-02
  • 打赏
  • 举报
回复
感谢各位的参与,谢谢。
to dvictor(victor)
javascript我不会,不过还是感谢你,我想你的回答应该可以解决我的问题,我研究研究吧
T2 2004-08-02
  • 打赏
  • 举报
回复
感谢各位的参与,谢谢。
to dvictor(victor)
javascript我不会,不过还是感谢你,我想你的回答应该可以解决我的问题,我研究研究吧
dvictor 2004-08-02
  • 打赏
  • 举报
回复
<link href="css/fc.css" rel="stylesheet" type="text/css">


<!--%@ include file = "/common/showparameter.jsp" %-->


<html>
<head>
<title>
费用编码管理
</title>
</head>
<body>
<font color="#3399FF" size="6" face="华文楷体">费用编码管理</font>
<p>


<form name="form1" method="POST" >
<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
var fybmtable_prevColumnBGColor;
var fybmtable_curURL = '#';
var fybmtable_curSelectedRow = -1;
var fybmtable_curObject = null;
function fybmtable_select( frame, id, url ) {
var obj = document.forms[0].fybmtable_selectedId;
if( obj == null )
return;
if( id != fybmtable_curSelectedRow ) {
fybmtable_curURL = url;
fybmtable_curSelectedRow = id;
if( fybmtable_curObject != null ) {
fybmtable_curObject.style.backgroundColor=fybmtable_prevColumnBGColor;
}
fybmtable_curObject = frame;
fybmtable_prevColumnBGColor=frame.style.backgroundColor;
frame.style.backgroundColor='#AAAAAA';
if( obj.length == null ) {
obj.checked=1;
} else {
obj[id-1].checked=1;
}
}
obj.value=id;
}
function fybmtable_doSubmit()
{
window.open(fybmtable_curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
function fybmtable_getWinLocationString()
{
var outstr;
outstr=",width=500,left="+Math.round((screen.width/2)-(500/2));
outstr+=",height=300,top="+Math.round((screen.height/2)-(300/2));
return outstr;
}
</SCRIPT>
<STYLE>
TABLE.nbtable { border-collapse: collapse; background-color: #FFFFFF; border: 2px solid black; width: 100%; }
TH.nbheadcol { border: 1px solid black; background-color: #DDDDDD; font-weight: bold; text-align: left; font-family:Verdana,Arial, Helvetica, sans-serif; font-size:10pt; }
TD.nbcol { border: 1px solid black; text-align: left; }
.nbbutton {
background-color: #FFFFFF;
padding-top: 2px;
padding-bottom: 2px;
text-decoration: none;
font-family:Verdana,Arial, Helvetica, sans-serif;
font-size:8pt;
font-weight:normal;
border-top : -1px solid #eeeeee;
border-left : 2px solid #eeeeee;
border-right : 2px solid #999999;
border-bottom: -1px solid #999999;
}
.evencolumn { font-family:Verdana,Arial, Helvetica, sans-serif; font-size:8pt; background-color:#FFFFFF; }
.oddcolumn { font-family:Verdana,Arial, Helvetica, sans-serif; font-size:8pt; background-color:#F7F7F7; }
</STYLE>
<INPUT TYPE="hidden" name="fybmtable_selectedId" value="-1">
<table class="nbtable" WIDTH="100%">
<tr>
<th class="nbheadcol">费用编号</th>
<th class="nbheadcol">费用名称</th>
<th class="nbheadcol">审批名称</th>
<th class="nbheadcol">备注</th>
</tr>
<tr class="evencolumn" onDBLClick="fybmtable_doSubmit()" onClick="fybmtable_select(this,1,'fybmupdata.jsp?fybh=0001&fymc=运费&spmc=Test1&bz=运费备注')">
<td class="nbcol">0001</td>
<td class="nbcol">运费</td>
<td class="nbcol">Test1</td>
<td class="nbcol">运费备注</td>
</tr>
<tr class="oddcolumn" onDBLClick="fybmtable_doSubmit()" onClick="fybmtable_select(this,2,'fybmupdata.jsp?fybh=0002&fymc=样品费&spmc=Test2&bz=样品费备注')">
<td class="nbcol">0002</td>
<td class="nbcol">样品费</td>
<td class="nbcol">Test2</td>
<td class="nbcol">样品费备注</td>
</tr>
<tr class="evencolumn" onDBLClick="fybmtable_doSubmit()" onClick="fybmtable_select(this,3,'fybmupdata.jsp?fybh=0003&fymc=餐旅费&spmc=Test3&bz=餐旅备注')">
<td class="nbcol">0003</td>
<td class="nbcol">餐旅费</td>
<td class="nbcol">Test3</td>
<td class="nbcol">餐旅备注</td>
</tr>
<tr class="oddcolumn" onDBLClick="fybmtable_doSubmit()" onClick="fybmtable_select(this,4,'fybmupdata.jsp?fybh=0004&fymc=医药费&spmc=Test4&bz=医药费备注')">
<td class="nbcol">0004</td>
<td class="nbcol">医药费</td>
<td class="nbcol">Test4</td>
<td class="nbcol">医药费备注</td>
</tr>
</table>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
function add_dosubmit(){
curURL="fybmupdata.jsp?fybmsubmit=添加&fybmtable_selectedId="+document.form1.fybmtable_selectedId.value;
window.open(curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
function edit_dosubmit(){
if (fybmtable_curURL!="#"){
curURL=fybmtable_curURL+"&fybmsubmit=修改&fybmtable_selectedId="+document.form1.fybmtable_selectedId.value;
window.open(curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
else{
curURL="fybmupdata.jsp?fybmsubmit=修改&fybmtable_selectedId="+document.form1.fybmtable_selectedId.value;
window.open(curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
}
function del_dosubmit(){
if (fybmtable_curURL!="#"){
curURL=fybmtable_curURL+"&fybmsubmit=删除&fybmtable_selectedId="+document.form1.fybmtable_selectedId.value;
window.open(curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
else{
curURL="fybmupdata.jsp?fybmsubmit=删除&fybmtable_selectedId="+document.form1.fybmtable_selectedId.value;
window.open(curURL,'详细信息','status=no,resizable=no'+fybmtable_getWinLocationString());
}
}
</SCRIPT>

<button name="fybmsubmit" onclick="add_dosubmit()" value="添加" Class="nbbutton">添 加</button>   
<button name="fybmsubmit" onclick="edit_dosubmit()" value="修改" Class="nbbutton">修 改</button>   
<button name="fybmsubmit" onclick="del_dosubmit()" value="删除" Class="nbbutton">删 除</button>


</form>
</body>
</html>




用了javascript。
peter638 2004-08-02
  • 打赏
  • 举报
回复
提交到本页,附加每条记录的序号,由序号判断所要生成的页.
sunboyyq 2004-08-02
  • 打赏
  • 举报
回复
up
T2 2004-08-02
  • 打赏
  • 举报
回复
up
longjing_g 2004-08-02
  • 打赏
  • 举报
回复
能否把每条记录都做成下拉式菜单。这样应该能解决你的问题。
加载更多回复(5)

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧