当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP Form 集合

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP Form 集合


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 385 ::
收藏到网摘: n/a

The Form collection is used to retrieve the values of form elements from a form that uses the POST method.
Form集合是用来获取表单中form元素的值的。这些form元素是用户通过POST方式发送的。

Note: If you want to post large amounts of data (beyond 100 kb) the Request.Form cannot be used.
注意:如果你要传输的是大容量数据(如:大于100kb),那么就不能使用Request.Form命令。

Syntax
语法

Request.Form(element)[(index)|.Count]

Parameter
参数
Description
描述
element Required. The name of the form element from which the collection is to retrieve values
必须组件。获取form集合中form元素的名称的值
index Optional. Specifies one of multiple values for a parameter. From 1 to Request.Form(parameter).Count.
可选组件。为一个参数指定众多值当中的一个值

Examples
举例

Example 1

You can loop through all the values in a form request. If a user filled out a form by specifying two values - Blue and Green - for the color element, you could retrieve those values like this:

<%
for i=1 to Request.Form("color").Count
Response.Write(Request.Form("color")(i) & "<br />")
next
%>

Output:

Blue
Green

Example 2

Consider the following form:

<form action="submit.asp" method="post">
<p>First name: <input name="firstname"></p>
<p>Last name: <input name="lastname"></p>
<p>Your favorite color:
<select name="color">
<option>Blue</option>
<option>Green</option>
<option>Red</option>
<option>Yellow</option>
<option>Pink</option>
</select>
</p>
<p><input type="submit"></p>
</form>

The following request might be sent:

firstname=John&lastname=Dove&color=Red

Now we can use the information from the form in a script: 

Hi, <%=Request.Form("firstname")%>. 
Your favorite color is <%=Request.Form("color")%>.

Output:

Hi, John. Your favorite color is Red.

If you do not specify any element to display, like this:

Form data is: <%=Request.Form%> 

the output would look like this:

Form data is: firstname=John&lastname=Dove&color=Red

评论 (0) All

登陆 | 还没注册?