<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<%
if(Request.Form("name").Item){  //判断表单的内容name是否存在，如果存在则将全部表单内容请求过来并写入数据库

	rs=Server.CreateObject("adodb.recordset"); //rsxg指修改
	rssql="select * from tab where id=" + Request.Form("id") ; //连接SQL语句用+，后面是请求id值
	rs.Open (rssql,conn,1,3 );
		
	rs("name")= Request.Form("name"); //将由表单中请求来的值赋给字段
	rs("sex")= Request.Form("sex");       //Request.Form() 是ASP请求表单变量的写法
	rs("level")= Request.Form("level");
	rs("img")= Request.Form("img");
	rs("info")= Request.Form("info");	

	rs.Update; //更新记录集，使插入的记录生效
	rs.close();//用后关闭这个记录集
	rs=null;   //清空它
	
	Response.Redirect("index.asp");
}
%>

<%
 rs=Server.createobject("adodb.recordset"); 
 rssql="select * from tab where id=" + Request.QueryString("id");
 rs.open(rssql,conn,1);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改记录</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="250" border="1" bordercolor="#000000">
  <tr>
    <td width="36">序号</td>
    <td><%=rs("id")%>
      <input name="id" type="hidden" id="id" value="<%=rs("id")%>" /></td>
  </tr>
  <tr>
    <td>姓名</td>
    <td>
      <input name="name" type="text" id="name" value="<%=rs("name")%>" />    </td>
  </tr>
  <tr>
    <td>性别</td>
    <td>
	<% if(rs("sex")==1){ %>
	  男<input name="sex" type="radio" value="1" checked="checked" />
	  女<input type="radio" name="sex" value="0" />
	<% }else{ %>
	  男<input name="sex" type="radio" value="1" />
	  女<input type="radio" name="sex" value="0" checked="checked"/>
	<% } %>
	 </td>
  </tr>
  <tr>
    <td>等级</td>
    <td>
        <select name="level" id="level">
		<%
		//定义下拉菜单，并与当前记录的现有数值进行比较，将其安排在合适的列表位
		var list = ["管理员","版主","会员"];
		for(i=0;i<list.length;i++){
			if(list[i]==rs("level")){
				Response.Write ("<option value=" + rs("level") +" selected>" + list[i] + "</option>");
			}else{
				Response.Write ("<option value=" + list[i] + " >" + list[i] + "</option>");
			}
		}
		%>
        </select> 	  
	</td>
  </tr>
  <tr>
    <td>简介</td>
    <td>
      <textarea name="info" rows="5" id="info"><%=rs("info")%></textarea>    </td>
  </tr>
  <tr>
    <td>图片</td>
    <td>
    <input name="img" type="text" id="img" value="<%=rs("img")%>" />
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center">
      <input type="submit" name="Submit" value="提交" />
       <input type="reset" name="Submit2" value="重置" />    </td>
    </tr>
</table>
</form>
</body>
</html>

<%
 rs.close();
 rs=null;
 conn.close();
 conn=null;
%>