主题:w的ACTION 是文件本身,浏览和查询在一个文件完成,根据提进行了修改,传递关键字,还不
sldd
[专家分:0] 发布于 2007-04-07 10:35:00
我编写了一个简单的设备浏览查询程序,进入页面后如下图所示,会分页显示所有设备,
[img]http://photos.album.mop.com/c03/32/32/83/857731/1175912387468.jpg[/img]
如果在搜索框内填入关键字搜索后,如果得到的记录少于每页显示的个数18个,程序是没有问题的,[img]http://photos.album.mop.com/c03/32/32/83/857731/1175912388067.jpg[/img]
如果大于18个,只要点击下一页,则显示的记录立即变为[b]所有记录[/b]的第二页,
[img]http://photos.album.mop.com/c03/32/32/83/857731/1175912388475.jpg[/img]
我的acton 是文件本身,请问在不改变我的显示思路的情况下可以解决这一问题吗?谢谢了!
最后更新于:2007-04-09 11:07:00
回复列表 (共10个回复)
沙发
yaozheng [专家分:28410] 发布于 2007-04-07 19:21:00
那是因为你在翻页的时候,没把关键字这个参数传过去。
板凳
sldd [专家分:0] 发布于 2007-04-08 10:10:00
看了你的签名挡,不好意思再问了,但是考虑到急用,还是问一问把,
[b]
(1)翻页时如何把关键字这个参数传过去,关键是一登陆就进入到此页面,这时是没有关键字的,
(2)只有当在查询框内填入关键字后,并且前面的下拉菜单内有按设备名,设备编号等不同的字段进行查询,[/b]
翻页的编码是我的网上找的,给个实例说明一下好吗?
3 楼
sldd [专家分:0] 发布于 2007-04-09 08:35:00
我把表单的代码拷贝下来
<form name="test" method="POST" action="deng_index.asp">
<p align="center"><font color="#FF0000"> 按</font>
<select size="1" name="sss">
<option value="设备名称">设备名称</option>
<option value="设备编号">设备编号</option>
<option value="设备规格型号">设备规格及型号</option>
<option value="设备用途分类">设备用途分类</option>
</select>
条件 <font color="#FF0000">输入查询的字符串</font>:
<input type="text" onFocus="this.value=''" name="ttt" size="20" style="font-family: 宋体; font-size: 9pt; color: #000064">
<input type="submit" value="查询" name="submit">
<input type="reset" value="全部重写" name="reset">
</p>
<%
const MaxPerPage=18
dim totalPut''''''''''''''''''
dim CurrentPage
dim TotalPages
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/system.asp") '## MS Access 2000 using virtual path
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.open strConnString
Set my_rs= Server.CreateObject("ADODB.Recordset")
%>
[b]<%dim sss,ttt
ttt=request.form("ttt")
if trim(request.form("sss"))<>"" then
select case request.form("sss")
case "设备名称"[/b]strSql ="select * from jhtdata where (设备名称 like '%"&trim(ttt)&"%') and (部门='"&myUpart&"') order by id Desc"
case "设备编号"
strSql ="select * from jhtdata where ( 设备编号 like '%"&trim(ttt)&"%') and (部门='"&myUpart&"') order by id Desc"
end select
else
strSql ="select * from jhtdata where 部门='"&myUpart&"' order by id Desc"
end if
my_rs.open strSql,my_Conn,1,1
if my_rs.eof and my_rs.bof then
response.write "<p align='center'> 还 没 有 任 何 设 备 </p>"%>
<table width="754" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#CCCCFF"><img border="0" src="images_oishbgl/Form.gif" align="absmiddle" width="14" height="11">
</td>
.....................
</tr>
</table>
[b]<%else
totalPut=my_rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"deng_index.asp"
showContent
showpage totalput,MaxPerPage,"deng_index.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
my_rs.move (currentPage-1)*MaxPerPage
showpage totalput,MaxPerPage,"deng_index.asp"
showContent
showpage totalput,MaxPerPage,"deng_index.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"deng_index.asp"
showContent
showpage totalput,MaxPerPage,"deng_index.asp"
end if
end if
my_rs.close
end if
set my_rs=nothing
my_conn.close
set my_conn=nothing%>
<%
sub showContent[/b]dim i
i=0
%>
</form>
4 楼
sldd [专家分:0] 发布于 2007-04-09 08:37:00
(1)翻页时如何把关键字这个参数传过去,关键是一登陆就进入到此页面,这时是没有关键字的,
(2)只有当在查询框内填入关键字后,并且前面的下拉菜单内有按设备名,设备编号等不同的字段进行查询,
5 楼
sldd [专家分:0] 发布于 2007-04-09 08:48:00
翻页的代码
<table border="0" width="754" bgcolor="#8080C0" align="center">
...................
1" style='border-collapse: collapse;table-layout:fixed;' x:str>
<tr align="center">
<td width="72" nowrap >设备名称</td>
<td width="87" >设备编号</td>
............................
<td colspan="2" > 管理栏 </td>
</tr>
<%do while not my_rs.eof %>
<tr align="center">
<td width="72" ><a href="#" onClick="MM_openBrWindow('view_inf.asp?view_id=<%=my_rs("id")%>','','scrollbars=yes,width=660,height=550')"><%=my_rs("设备名称")%></a></td>
<td width="87" ><%=my_rs("设备编号")%></td>
....................
</td>
<td width="38" >
<%
i=i+1
if i>=MaxPerPage then exit do
my_rs.movenext
loop
%>
</table>
</table>
<%
end sub
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<p align='center'> "
if CurrentPage<2 then
response.write "<font color='#000080'><a href="&filename&"?page=1>首页</a> 上一页</font> "
else
response.write "<a href="&filename&"?page=1>首页</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>个记录 <b>"&maxperpage&"</b>个记录/页</font> "
response.write "<font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength=4 class=smallInput value="&Currentpage&"> "
response.write "<input class=buttonface type='submit' value='Go' name='cndok' > "
end function
6 楼
sldd [专家分:0] 发布于 2007-04-09 09:01:00
翻页时候,如何把
查询的关键字传到下一页啊
7 楼
sldd [专家分:0] 发布于 2007-04-09 09:55:00
首先得有接受关键字这一参数的地方
我这儿的查询关键字是ttt=request.form("ttt")
如何修改接收参数的语句呢???
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
这一句该如何修改呢?
showpage totalput,MaxPerPage,"deng_index.asp"
8 楼
sldd [专家分:0] 发布于 2007-04-09 10:36:00
我这样修改了,为什么还传不过去???
[b]keyword=Trim(Request("key"))[/b]
if trim(request.form("sss"))<>"" then
select case request.form("sss")
case "设备名称"
strSql ="[b]select * from jhtdata where (设备名称 like '%"&keyword&"%') and (部门='"&myUpart&"') order by id Desc" [/b]
.............................
if CurrentPage<2 then
response.write "<font color='#000080'><a href="&filename&"?key="&keyword&"&page=1>首页</a> 上一页</font> "
else
response.write "<a href="&filename&"?key="&keyword&"&page=1>首页</a> "
response.write "<a href="&filename&"?key="&keyword&"&page="&CurrentPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else
response.write "<[b]a href="&filename&"?key="&keyword&"&page="&(CurrentPage+1)&">"[/b]
response.write "下一页</a> <a href="&filename&"?key="&keyword&"&page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>个记录 <b>"&maxperpage&"</b>个记录/页</font> "
9 楼
sldd [专家分:0] 发布于 2007-04-09 10:38:00
嘿嘿,顶成热贴
10 楼
sldd [专家分:0] 发布于 2007-04-09 10:50:00
再次说明,进入页面后,会分页显示所有设备,因为此时还没有任何关键字
当填入关键字后,会显示含有关键字的记录,当翻下页时,就会显示所有记录第二页
我按照yaozheng专家的提示,作了修改,为什么还不行呢?????
还有我的ACTION 是文件本身,也就是说浏览和查询在一个文件完成,不填写关键字是浏览所有,填写关键字后,只浏览相关
我来回复