查询时传递一个查询字串,删除就返回Index值进行删除就可以了
解决方案 »
- 想要实现log4j对用户的操作进行日志记录,请大家帮忙
- webwork标签,如果判断一个LIST的长度或是有无数据!谢谢!
- 如何实现meclipse定时保存??
- 急急急!!!spring中配置AOP问题
- 关于web程序
- 求教:在线编辑器fckEditor或者其他编辑器,如何控制页面表格中的每个单元格
- Javamail发邮件,yahoo邮箱收到后出现附件乱码问题。
- Tomcat6.0运行时出现 500错误,小弟新手,迷惑中,大虾援助。。。。
- 来深圳一个多月,找到工作了!
- 谁帮帮我?
- 请问Jbuilder5和ViusalAge for Java哪个开发工具更好
- 关于一个green hand的jsp问题,我已经没办法了!!!
<SCRIPT LANGUAGE=JAVASCRIPT>
function lookUp(){
var str="";
if((InstrNo.value.indexOf("'") == -1) && (InstrName.value.indexOf("'") == -1)
&& (ModelNo.value.indexOf("'") == -1) && (Provider.value.indexOf("'") == -1))//清除單引號
{
InstrNo.value=clearBlank(InstrNo.value);
if (InstrNo.value.length>0)
str="InstrNo "+InstrNoSymbol.value+" '"+InstrNo.value+"' and";
InstrName.value=clearBlank(InstrName.value);
if(InstrName.value.length>0)
str=str+" InstrName "+InstrNameSymbol.value+" '"+InstrName.value+"' and";
ModelNo.value=clearBlank(ModelNo.value);
if(ModelNo.value.length>0)
str=str+" ModelNo "+ModelNoSymbol.value+" '"+ModelNo.value+"' and";
Provider.value=clearBlank(Provider.value);
if(Provider.value.length>0)
str=str+" Provider "+ProviderSymbol.value+" '"+Provider.value+"' and";
if(str.length==0)
alert("請至少輸入一筆查詢資料!");
else{
returnValue=str.substring(0,str.length-4);//傳回查詢字串,去掉最後的and
window.close();
}
}
else{
alert("請輸入正確的查詢條件!");
return false;
}
}
function myCancel(){//查詢的返回值
returnValue="cancel";
window.close();
}
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<html>
<head>
<title>請選擇以下查詢條件:</title>
<script language=javascript src="public_main.js"></script>
<body>
<table border="1" width="100%" style="border-collapse: collapse; font-size: 9pt">
<tr>
<td width="30%" align="right" >儀器編號:</td>
<td width="20%"><select name="InstrNoSymbol" style="width:100%; font-size: 9pt"><OPTION value=" =">=</OPTION><OPTION value=" like">like</OPTION></select></td>
<td width="50%">
<input name="InstrNo" onkeypress="jscript:btnpress()" style="width:100%; font-size: 9pt">
</td>
</tr>
<tr>
<td width="30%" align="right" >儀器名稱:</td>
<td width="20%"><select name="InstrNameSymbol" style="width:100%; font-size: 9pt"><OPTION value=" =">=</OPTION><OPTION value=" like">like</OPTION></select></td>
<td width="50%">
<input name="InstrName" onkeypress="jscript:btnpress()" style="width:100%; font-size: 9pt">
</td>
</tr>
<tr>
<td width="30%" align="right" >儀器型號:</td>
<td width="20%"><select name="ModelNoSymbol" style="width:100%; font-size: 9pt"><OPTION value=" =">=</OPTION><OPTION value=" like">like</OPTION></select></td>
<td width="50%"><input name="ModelNo" onkeypress="jscript:btnpress()" style="width:100%; font-size: 9pt"></td>
</tr>
<tr>
<td width="30%" align="right" >供應商:</td>
<td width="20%"><select name="ProviderSymbol" style="width:100%; font-size: 9pt"><OPTION value=" =">=</OPTION><OPTION value=" like">like</OPTION></select></td>
<td width="50%">
<input name="Provider" onkeypress="jscript:btnpress()" style="width:100%; font-size: 9pt"></td>
</tr>
</table>
<hr size="1" style="margin-top: 0; margin-bottom: 0" color="#0000FF">
<P align="right" style="margin-top: 0; margin-bottom: 0">
<input type="button" value="確 定" onclick="javascript:lookUp();" style="cursor: hand; font-size: 9pt; color: #c00000; background-color: #ffffff; border-style: solid; border-width: 1"> |
<input type="button" value="取 消" onclick="javascript:myCancel();" style="cursor: hand; font-size: 9pt; color: #c00000; background-color: #ffffff; border-style: solid; border-width: 1">
</p>
</body>
</html>
这是一个简单的主页面:
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<html>
<head><title>Instrument_main</title>
</head>
<script language=javascript>
//-------------------------返回查詢字串-----------------------------------
function lookUp(){
var QueryStr=window.showModalDialog("instrument_lookup.jsp","","dialogWidth:19;dialogHeight:11;center:1;status:0;scrollbars:0;caption:0");
if (QueryStr!=null && QueryStr!="cancel" && QueryStr.length != 0 ){
document.frmquery.lookup.value=QueryStr;
document.frmquery.submit();
}
}</script>
<%@ page
import="java.sql.*,java.text.*,java.io.*,java.lang.*,java.util.*"
%>
<body>
<%
Statement stmt;
ResultSet rs;
try{
stmt=((Connection)application.getAttribute("conn")).createStatement();
}
catch(Exception e){
throw new Exception ("系統設定值已變更,請重新登入再試!");
} /*//刪除資料
String strdel=request.getParameter("delSQL");
//out.println("<script language=javascript>alert("+strdel+");</script>");
try{
if(!strdel.equals("") && strdel!=null)
stmt.executeUpdate("delete from Instrument where IdxInstrNo in ("+strdel+")");
}
catch (Exception e){
//out.println(e.getMessage());
}*/ String Str=request.getParameter("lookup");
if(Str==null || Str.equals("")){
if(varOrder.equals(""))
Str="select * from Instrument ";
else
Str="select * from Instrument where "+request.getParameter("lookup")+" order by IdxInstrNo DESC";
rs=stmt.executeQuery(Str);
%>
<div align="justify">
<table border="0" width=100% height="20" cellspacing="0" cellpadding="0">
<tr>
<td width=100% height="7" valign="middle">
<p align="left">當前位置: <a href="index.jsp">主頁</a> | 基本資料 | 量測儀器設定
</td>
</tr>
</table>
<p style="margin-top:0;margin-bottom: 5" align="right">
<input type="button" value="刪除" style="cursor: hand; font-size: 9pt; color: #c00000; background-color: #ffffff; border-style: solid; border-width: 1" onclick=myDeleteDate()>> |
<input type="button" value="查詢" style="cursor: hand; font-size: 9pt; color: #c00000; background-color: #ffffff; border-style: solid; border-width: 1" onclick=lookUp()>
</p>
</div>
<div>
<table border="0" width="100%" cellspacing="0" cellpadding="0" style="font-size: 9pt" height="18">
<tr bgcolor="#000080" style="color:#FFFFFF" height="18" >
<td width=8% ><p align="left">編號</td>
<td width=3% > <input type="checkbox" name="mySelectALL" style="cursor:hand" ></td>
<td width=23% style="cursor:s-resize" > 儀器編號</td>
<td width=22% style="cursor:s-resize" >儀器名稱</td>
<td width=22% style="cursor:s-resize" )>儀器型號</td>
<td width=22% style="cursor:s-resize" )>供應商</td>
</tr>
</table>
</div>
<div id="Layer1" style="position:relative; width:100%; height:70%; z-index:-1; overflow: auto; visibility: visible; ">
<table border="0" width="100%" cellspacing="1" cellpadding="0" style="font-size: 9pt" height="18">
<%
int varIdx=1;
try{
while (rs.next()){
int No=rs.getInt("IdxInstrNo");
out.println("<TR ID='myTR' style='cursor:hand' ");
if((varIdx%2)==0)
out.println("bgcolor='#D5E8F9'>");
else
out.println("bgcolor='#FFFFFF'>");
out.println("<TD width=8% align='left'><img src='images/idx_instrument.gif'>"+varIdx+"</TD>");
out.println("<TD width=4% ><input type=checkbox name='myCHK' value='"+No+"' onclick='javascript:this.checked=!this.checked;'</TD>");
out.println("<TD width=22% >"+rs.getString("InstrNo")+"</TD>");
out.println("<TD width=22% >"+rs.getString("InstrName")+"</TD>");
out.println("<TD width=22% >"+rs.getString("ModelNo")+"</TD>");
out.println("<TD width=20% >"+rs.getString("Provider")+"</TD></TR>");
varIdx++;
}
rs.close();
rs=null;
stmt.close();
stmt=null;
}
catch (Exception e){
out.println(e.getMessage());
}
%>
</table>
</div>
</body>
<form method="post" action="instrument_main.jsp" name="frmquery" style="margin-top: 0; rgin-bottom: 0">
<input name="delSQL" type="hidden" value="">
<input name="lookup" type="hidden" value="">
</form>
</html>