发一个自己写的用表单本页提交本页处理的code!
<%
id=request("id")
set rs=server.CreateObject("adodb.recordset")
sql="select * from class where id="&id
rs.open sql,conn,3,3
%>
<table width="730" height="634" border="1">
<tr>
<td width="706" height="583">
<div id="apDiv1">
<form action="edit_class.asp?action=edit&id=<%=rs("id")%>" method="post" name="form"> <input type="text" value="<%=rs("class")%>" name="renane" class="input">
<input type="submit" value="修改" class="click_pw">
<input type="button" value="返回" class="click_pw"onClick="javascript:window.top.mainFrame.location='admin_viewlei.asp';">
</form>
</div>
</td>
</tr>
<tr>
<td height="26"> </td>
</tr>
</table>
<%
rs.close
set rs=nothing
if request("action")="edit" then
call edit()
end if
%>
<%
sub edit()
dim rename
rename=request.Form("renane")
if rename="" then
Response.Write "<Script>alert('请正确输入!');history.go(-1);</Script>"
Response.End
else
set rs=server.CreateObject("adodb.recordset")
sql="select * from class where id="&id
rs.open sql,conn,3,3
rs("class")=rename
rs.update
rs.close
set rs=nothing
response.Redirect("admin_viewlei.asp")
end if
end sub
%>
原理:
用表单提交的时候action="edit_class.asp?action=edit&id=<%=rs("id")%>" ,即传递一个action的值给本页,点击提交按钮时候用:
if request("action")="edit" then
call edit()
来判断,action值符合要求后,然后调用定义好的edit()函数!