求单表的二级联动下拉框提交页面代码

Redball 2005-08-24 10:07:24
我SQL数据库只有一张表
数据库服务器:192.168.6.15
数据库:datalog
登录用户名密码:windows集成验证
表名:聊天记录
字段:用户(nvarchar) 时间(datetime) 内容(ntext)
数据存储量:10万级

我就是想实现一个查询界面,查询界面有两个下拉框,一个是用户,一个是时间,当选取用户后,时间下拉框自动读取当前包含当前用户的记录的时间(只显示日期),然后点击提交按钮,在弹出新页面的对话框中显示这个用户当日的记录。
如果实现了以上功能当然就OK了,不过我还希望:
1,提交后下拉框能保留最一次选择值而不是复位。
2,结果最好能有分页显示。

...全文
283 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Redball 2005-08-29
  • 打赏
  • 举报
回复
基本调试成了,谢谢~哈哈~
Redball 2005-08-29
  • 打赏
  • 举报
回复
sample2.asp
这个网页是干什么用的阿,调试到这里出问题了。
jingxiaoping 2005-08-24
  • 打赏
  • 举报
回复
<!--本网站设计、程序、数据结构均属于QQ:7631746 richejxp所有-->
<!-- #include file="../inc/conn.asp" -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body>
<%
username=request("username")
userdate=request("userdate")
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<form action="sample2.asp" method="post" name="form1">
<tr>
<td width="100%" colspan="2">
<select size="1" name="username" onchange="document.form1.submit();">
<%
sql="select distinct name from sample3 order by name"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.recordcount<>0 then
while not rs.eof
name=rs("name")
%>
<option <%if username=name then%>selected<%end if%> value=<%=name%>><%=name%></option>
<%
rs.movenext
wend
end if
rs.close
%>
</select>
<select size="1" name="userdate">
<option value="">--请选择--</option>
<%
sql="select distinct sdate from sample3 where name='"&username&"' order by sdate desc"
rs.open sql
if rs.recordcount<>0 then
while not rs.eof
if sdate<>formatdatetime(rs("sdate"),2) then
sdate=formatdatetime(rs("sdate"),2)
%>
<option <%if userdate=sdate then%>selected<%end if%> value="<%=sdate%>"><%=sdate%></option>
<%
end if
rs.movenext
wend
end if
rs.close
%>
</select>
<input type="submit" value="提交" name="submit1">
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="33%" height="25" align="center">序号</td>
<td width="33%" height="25" align="center">用户</td>
<td width="34%" height="25" align="center">时间</td>
</tr>
<%
sql="select name,sdate from sample3 where 1=1"
if username<>"" then
sql=sql&" and name='"&username&"'"
end if
if userdate<>"" then
sql=sql&" and sdate between '"&userdate&"' and '"&dateadd("d",1,userdate)&"'"
end if
rs.open sql
ye=cshu(request("ye"))
jumpto=cshu(request("jumpto"))
if jumpto<>0 then
ye=jumpto
end if
rs.pagesize=20
if ye<1 then ye=1
if ye>rs.pagecount then ye=1
if rs.recordcount<>0 then
pag="sample2.asp"
if username<>"" then
linkstr="?"
pag=pag&linkstr&"username="&username
end if
if userdate<>"" then
if username<>"" then
linkstr="&"
else
linkstr="?"
end if
pag=pag&linkstr&"username="&username
end if
rs.absolutepage=cint(ye)
pgsize=rs.pagesize
rscount=rs.recordcount
pgcount=rs.pagecount
i=1
while not rs.eof
bm=(ye-1)*pgsize+i
name=rs("name")
sdate=rs("sdate")
%>
<tr>
<td width="33%" height="25" align="center"><%=bm%></td>
<td width="33%" height="25" align="center"><%=name%></td>
<td width="34%" height="25" align="center"><%=sdate%></td>
</tr>
<%
rs.movenext
i=i+1
wend
end if
rs.close
set rs=nothing
if linkstr="" then
linkstr="?"
end if
%>
</table>
</td>
</tr>
<tr>
<td width="74%" height="20">
总<span class="red"><%=rscount%></span>条信息
每页<span class="red"><%=pgsize%></span>条
页次:<span class="red"><%=ye%>/<%=pgcount%></span>
转到:<input type="text" value="<%=ye%>" name="jumpto" style="height: 16px; font-size: 9pt; border-left-style: none; border-left-width: 1; border-right-style: none; border-right-width: 1; border-top-style: none; border-top-width: 1; border-bottom: 1 solid #000000" size="3">页
<input type="button" onclick="javascript:document.form1.submit();" value="GO" name="submit2" style="background-color: #DBDBDB; width: 23; height: 18; font-size: 9pt; border-style: solid; border-width: 1">
</td>
<td width="26%" height="20" align="right">
<%if ye<=1 then%>首页<%else%><a href="<%=pag%><%=linkstr%>ye=1" class="red">首页</a><%end if%> 
<%if ye<=1 then%>上一页<%else%><a href="<%=pag%><%=linkstr%>ye=<%=ye-1%>" class="red">上一页</a><%end if%> 
<%if ye>=pgcount then%>下一页<%else%><a href="<%=pag%><%=linkstr%>ye=<%=ye+1%>" class="red">下一页</a><%end if%> 
<%if ye>=pgcount then%>最后一页<%else%><a href="<%=pag%><%=linkstr%>ye=<%=pgcount%>" class="red">最后一页</a><%end if%>
</td>
</tr>
</form>
</table>
</form>
</body>

</html>
<%
conn.close
set conn=nothing
%>

数据结构:

名称:sample3

id(序号)(int类型)(自动增加)
name(用户)(nvarchar)
sdate(时间)(datetime)
detail(内容)(ntext)
Redball 2005-08-24
  • 打赏
  • 举报
回复
znjgress(ASP深着那) :
谢谢你的代码,不过我没看出来是干什么用的~:P
Redball 2005-08-24
  • 打赏
  • 举报
回复
jingxiaoping(我喜欢曾凯娟http://www.zkjcn.com) :
你指的是结果页面吧,我想再次提交的时候应该是要刷新的。
Redball 2005-08-24
  • 打赏
  • 举报
回复
不知道楼上指哪一部分,结果页面还是刷新的好吧。
尚和空四 2005-08-24
  • 打赏
  • 举报
回复
<select name="dept" onchange="document.form2.submit();">
<option><%= dept %></option>
<%while not rs.eof and not rs.bof %>
<option value="<%= rs("dept") %>"><%=rs("dept")%></option>
<%
rs.moveNext
wend
rs.close
set rs = nothing
%>
</select>
jingxiaoping 2005-08-24
  • 打赏
  • 举报
回复
想刷新页面,还是无刷新呢。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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