高手们:我想这样做,不知行不行呢?在本页内提交,结果返回在本页里?

coollele 2000-06-18 02:47:00
我想在本页内,做个查询,当选则了性别后,将结果返回,但结果不另起一页,而是在本页内,这样行吗?如果行的话,请将代码告知!谢谢!!coollele@helpok.com

我的代码如下:
<P>找朋友</P>
<br><br><br>
<form action="/cgi_bin/findfriend.asp" method="post" name="form1" >
<P>性别:<SELECT id=select1 name=select1>
<OPTION selected value=""></OPTION>
<OPTION value="男">男</OPTION>
<OPTION value="女">女</OPTION></SELECT></P>
<P><input type="submit" name="form1" value="提交">
<input type="reset" name="reset" value="清除">
<br>
</form> <p></p></td></tr>
</table>
<table width="100%" border="0"><tr>
<td width="20%"><div align="center">昵称:</div></td>
<td width="10%"><div align="center">性别:</div></td>
<td width="10%"><div align="center">年龄:</div></td>
<td width="20%"><div align="center">邮箱:</div></td>
<td width="40%"><div align="center">简介:</div></td></tr>
<%
dim sex
sex=Request.Form("sex")
sql = "select nickname,sex,age,email,icq,http,information from guys where sex='& sex & '"
set rs = conn.execute(sql)
do until rs.EOF
%>
</table>
<table width="100%" border="0"><tr>
<td width="20%">
<div align="center"><A href="/cgi_bin/finduse.asp"><%=rs("nickname")%></a></div></td>
<td width="10%"> <div align="center"><%=rs("sex")%></div></td>
<td width="10%"> <div align="center"><%=rs("age")%></div></td>
<td width="20%"> <div align="center"><a href="mailto:<%=rs("email")%>"><%=rs("email")%> </a></div></td>
<td width="40%"> <div align="center"><%=rs("information")%></div></td>
</tr></table>

<%
rs.MoveNext
loop
Rs.Close:set Rs = nothing
conn.Close:set conn = nothing
%>
<TABLE bgColor=#f5f5f5 border=0 cellPadding=0 cellSpacing=0 width="100%">
<TR><TD height="15"></TD></TR>

</TABLE>
<A href="" onclick="history.back()">返回</A>
<P></P></center></div>
...全文
197 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
siyu 2000-06-20
  • 打赏
  • 举报
回复
当选择“男”、“女”时程序没有反应,我想是因为rs为eof,你检查一下你的sql写得对不对,可能是这里错了:
sql = "select nickname,sex,age,email,icq,http,information"& _
" from guys where sex='"& sex & "'"
coollele 2000-06-20
  • 打赏
  • 举报
回复
这样写不行呀!只会得出所有的数据来,当你去选则男,或女时,没有反应的。还只是会得出所有的数据来。。。是不是我写错了, 请看下面的代码:
<P>找朋友</P>
<br><br><br>
<form action="/cgi_bin/findfriend.asp" method="post" >

<P>性别:<SELECT id=select1 name=select1>
<OPTION
selected value=""></OPTION>
<OPTION value="男">男</OPTION>
<OPTION value="女">女</OPTION></SELECT></P>
<P>
<input type="submit" name="form1" value="提交">
<input type="reset" name="reset" value="清除">
<br>
</form> <p></p>
</td>
</tr>


</table>


<table width="100%" border="0">
<tr><td width="20%"><div align="center">昵称:</div></td>
<td width="10%"><div align="center">性别:</div></td>
<td width="10%"><div align="center">年龄:</div></td>
<td width="20%"><div align="center">邮箱:</div></td>
<td width="40%"><div align="center">简介:</div></td>
</tr>
<%
dim sex
sex=Request.Form("sex")
Response.Write sex

if trim (sex)="" then
sql = "select nickname,sex,age,email,icq,http,information from guys"
else
sql = "select nickname,sex,age,email,icq,http,information"& _
" from guys where sex='& sex & '"
end if
set rs = conn.execute(sql)
do until rs.EOF
%>
</table>
<table width="100%" border="0">
<tr>
<td width="20%">
<div align="center"><A href="/cgi_bin/finduse.asp"><%=rs("nickname")%></a></div></td>

<td width="10%">
<div align="center"><%=rs("sex")%></div></td>

<td width="10%">
<div align="center"><%=rs("age")%></div></td>

<td width="20%">
<div align="center"><a href="mailto:<%=rs("email")%>"><%=rs("email")%> </a></div></td>

<td width="40%">
<div align="center"><%=rs("information")%></div></td>
</tr>
</table>

<%
rs.MoveNext
loop

Rs.Close:set Rs = nothing
conn.Close:set conn = nothing
%>
<TABLE bgColor=#f5f5f5 border=0 cellPadding=0 cellSpacing=0 width="100%">
<TR><TD height="15"></TD></TR>

</TABLE>
<A href="" onclick="history.back()">返回</A>
<P></P></center></div>
waynezlee 2000-06-19
  • 打赏
  • 举报
回复
ghj1976 的方法很对。
如果你不想让页面刷新:
1.也可以用iframe(比较苯的方法)
2.建议试一试Remote Scripting.

另:<select onchange="document.from1.submit();">是比用submit钮更好玩吧。
蝈蝈俊 2000-06-18
  • 打赏
  • 举报
回复
<%
dim sex
sex=Request.Form("sex")
sql = "select nickname,sex,age,email,icq,http,information from guys where sex='& sex & '"
set rs = conn.execute(sql)
do until rs.EOF
%>

这应该分两部分:
第一次进入时sex 无值,
<%
dim sex
sex=Request.Form("sex")
if trim(sex) = ""
sql = "select nickname,sex,age,email,icq,http,information from guys "
'全部
else
'部分
sql = "select nickname,sex,age,email,icq,http,information "&_
"from guys where sex='& sex & '"
end if
set rs = conn.execute(sql)
do until rs.EOF
%>


masterz 2000-06-18
  • 打赏
  • 举报
回复
Yes, you can do that very easily in this way:
Suppose your asp file name is mypagename, then your use this file name in your form.But you need to do is add some code for dealing with the field of the form when the asp page is called.
<form action="mypagename.asp" method="post" >

28,391

社区成员

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

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