永发信息网

jsp逐行删除按钮

答案:3  悬赏:10  手机版
解决时间 2021-05-10 01:33
  • 提问者网友:藍了天白赴美
  • 2021-05-09 16:06
<body>
<div id="container">
<div id="navigation">
<ul>

<li><a href="min3.jsp">登记情况</a></li>
<li><a href="min2.jsp">客户资料</a></li>
<li><a href="min1.jsp">账单记录</a></li>
<li><a href="min.jsp">房间资料</a></li>
<li><a href="index.jsp">主页</a></li>
</ul>
</div>
<div id="content">
<%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=test", "laogao", "laomao");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from FJZL");
out.print("<table width=80% border='1' align=center cellspacing= 0 bordercolor= #CC0000>");
out.print("<tr scope=row>");
out.print("<th scope=col>房间代码</th>");
out.print("<th scope=col>房间类型</th>");
out.print("<th scope=col>房间状态</th>");
out.print("<th scope=col>房间价格</th>");
out.print("<tr>");
while (rs.next()) {
out.print("<TR height=30>");
out.println("<th scope=row>" + rs.getString(1) + "</th>");
out.println("<th>" + rs.getString(2) + "</th>");
out.println("<th>" + rs.getString(3) + "</th>");
out.println("<th>" + rs.getString(4) + "</th>");
out.println("<th width=35>" +"<form action=xiugai.jsp><input type=submit value= 修改 /></form>" + "</th>");
out.println("<th width=35>" +"<form action=shanchu.jsp><input type=submit value= 删除 /></form>" + "</th>");
out.print("</TR>");
}
out.print("</table>");
rs.close();
stmt.close();
con.close();
%>
</div>
</div>
</body>
我这里是用打印的方式输出表的,我想问一下怎么在按下删除按钮或修改按钮时能把 rs.getString(1) 的值传递到shanchu.jsp或xiugai.jsp里
最佳答案
  • 五星知识达人网友:春色三分
  • 2021-05-09 16:29
加一个隐藏的值 你参考我的。
<body>
<div id="container">
<div id="navigation">
<ul>

<li><a href="min3.jsp">登记情况</a></li>
<li><a href="min2.jsp">客户资料</a></li>
<li><a href="min1.jsp">账单记录</a></li>
<li><a href="min.jsp">房间资料</a></li>
<li><a href="index.jsp">主页</a></li>
</ul>
</div>
<div id="content">
<%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=test", "laogao", "laomao");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from FJZL");
out.print("<table width=80% border='1' align=center cellspacing= 0 bordercolor= #CC0000>");
out.print("<tr scope=row>");
out.print("<th scope=col>房间代码</th>");
out.print("<th scope=col>房间类型</th>");
out.print("<th scope=col>房间状态</th>");
out.print("<th scope=col>房间价格</th>");
out.print("<tr>");
while (rs.next()) {
out.print("<TR height=30>");
out.println("<th scope=row>" + rs.getString(1) + "</th>");
out.println("<th>" + rs.getString(2) + "</th>");
out.println("<th>" + rs.getString(3) + "</th>");
out.println("<th>" + rs.getString(4) + "</th>");
out.println("<th width=35>" +"<form action=xiugai.jsp><input type='submit' value= '修改' /></form>" + "</th>");
out.println("<th width=35>" +"<form action=shanchu.jsp><input type='submit' value= '删除' /><input type='hidden' name='delID' value='"+rs.getString(1) +"'/></form>" + "</th>");
out.print("</TR>");
}
out.print("</table>");
rs.close();
stmt.close();
con.close();
%>
</div>
</div>
</body>
全部回答
  • 1楼网友:风格不统一
  • 2021-05-09 18:08

<form action="shanchu.jsp? str = <%rs.getString(1)%>"><input type=submit value= 删除 /></form>

str 是你自定义的一个名称

在另一个jsp页面中用 String str = request.getParameter("str"); 获取

  • 2楼网友:独行浪子会拥风
  • 2021-05-09 17:06
<form action=xiugai.jsp><input type=submit value= 修改 /></form> <form action=shanchu.jsp><input type=submit value= 删除 /></form> 修改成 <a href='xiugai.jsp?id= rs.getString(1) > 修改</> <a href='shanchu.jsp?id= rs.getString(1) > 删除</> 然后分别在xiugai.jsp和shanchu.jsp页面接收id传过来的值
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯