关于参数传递不明白
见下代码:<%Dim forumid,Rs,Sql
forumid = Request("forumid")这一句是从前面代码中的获取URL来的,它与下面3个带有不同色彩的 forumid 之间有什么关系?变量如何传递的?
%>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="60%" height="26"> 当前版块:<%=GetForumName(forumid)%> > 发表帖子</td>
<td width="40%" align="right"></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#008080">
<form name="postFrm" method="post" action="?action=post&forumid=<%=forumid%>" onSubmit="return(ChkpostFrm());">
<tr height=25>
<td colspan="2" align="center" background="images/bj.gif" bgcolor="#FFFFFF"><strong>发表帖子</strong></td>
</tr>
<tr height=25>
<td width="19%" align="right" bgcolor="#FFFFFF">论坛分类:</td>
<td width="81%" bgcolor="#FFFFFF"> <select name="ForumID">
<%
Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "Select * From [Forum] Order By ID Asc"
Rs.Open Sql,Conn,1,1
If Not Rs.Eof And Not Rs.Eof Then
Do While Not Rs.Eof
%>
<option <% If CInt(forumid)=CInt(Rs("ID")) Then Response.Write "selected" %> value="<%=Rs("ID")%>"><%=Rs("Name")%></option>
<%
Rs.MoveNext
Loop
End If
Rs.Close
Set Rs=nothing
%>
</select></td>
</tr>
<tr height=25>
<td align="right" bgcolor="#FFFFFF"><font color=#ff0000>*</font>帖子主题:</td>
<td bgcolor="#FFFFFF"> <input name="Title" type="text" size="51"> </td>
</tr>
<tr height=25>
<td align="right" bgcolor="#FFFFFF">帖子内容:</td>
<td bgcolor="#FFFFFF"> <textarea name="Content" cols="50" rows="12"></textarea></td>
</tr>
<tr height=25>
<td align="right" bgcolor="#FFFFFF"> </td>
<td height="35" bgcolor="#FFFFFF"> <input type="submit" name="Submit2" value="发表帖子"></td>
</tr></form>
</table></td>
</tr>
</table>
</body>
</html>
<% If Request("action")="post" Then
Call Save_Post()
End If
Sub Save_Post()
Dim forumid,Title,Content,Rs,Sql
forumid = Request.Form("forumid")
Title = Trim(Request.Form("Title"))
Content = Trim(Request.Form("Content"))
Set Rs = Server.CreateObject("ADODB.RecordSet")
Sql = "Select * From [Info]"
Rs.Open Sql,Conn,2,3
Rs.AddNew
Rs("forumid") = forumid
Rs("User") = Session("User")
Rs("Title") = Title
Rs("Content") = Content
Rs("PostTime") = Now()
Rs("IP") = Request.ServerVariables("REMOTE_ADDR")
Rs.Update
Rs.Close
Set Rs = nothing
Response.Write "<Script>alert('恭喜您,帖子发表成功!');location.href='list.asp?forumid="&forumid&"';</Script>"
End Sub
%>
[ 本帖最后由 sylknb 于 2010-3-6 16:21 编辑 ]