下面是我写ASP 程序时所碰到的一个问题:
我想选择男,那么就只显示性别为男的学生,
如果选择女,那么就只显示性别为女的学生,
下面的代码为什么实现不了,请各位大师指教
<!--#include file="conn.asp"-->
<html>
<head>
<title> 学生情况表登记 </title>
</head>
<script language=javascript>
function bao(s)
{
   <%
    session("this_sex")=s
   %>
}
</script>
<body>
<form method="post" action="select02.asp">
<p align=center>
<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)">
<option value="全部">全部
<option value="男" <% if session("this_sex")="男" then Response.write "selected" %> >男
<option value="女" <% if session("this_sex")="女" then Response.write "selected" %> >女
</select>
<input class="button" type="submit" name="Submit" value="确定">
</p>
<TABLE width="680" border=0 align="center" cellPadding=4 cellSpacing=1 bgcolor="#CCCCCC" class="table">
   <tr align="center"> 
     <td width="48" bgcolor="#f7f7f7">编号</td>
     <td width="166" bgcolor="#f7f7f7">姓名</td>
     <td width="130" bgcolor="#f7f7f7">性别</td>
     <td width="180" bgcolor="#f7f7f7">家庭地址</td>
     <td width="150" bgcolor="#f7f7f7">毕业学校</td>
   </tr>
    <% 
    dim rs,sql
      set rs = server.createobject("adodb.recordset")
    if session("this_sex")="" or session("this_sex")="全部" then
          sql="select * from student"
        end if
 
        if session("this_sex")="男" then
          sql="select * from student where sex='男'"
        end if
        if session("this_sex")="女" then
          sql="select * from student where sex='女'"
        end if
rs.open sql,conn,1,1
          dim i 
     i=0 
    do while not rs.eof
    %> 
        <tr align="center"> 
           <td width="48" bgcolor="#f7f7f7"><%=i+1%></td>
           <td width="166" bgcolor="#f7f7f7"><%=rs("name")%></td>
           <td width="130" bgcolor="#f7f7f7"><%=rs("sex")%></td>
           <td width="180" bgcolor="#f7f7f7"><%=rs("addr")%></td>
           <td width="150" bgcolor="#f7f7f7"><%=rs("gradeby")%></td>
        </tr>
    <% 
    i=i+1
    rs.movenext 
    loop 
       rs.close 
    %>
</table>
</form>
</body>                              
</html>

											
	    

