Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

ASP Form 集合


❮ 完整 Request 对象参考

Form 集合用于检索使用 POST 方法的表单中表单元素的值。

语法

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

参数 描述
element 必需。要从其检索值的表单元素的名称
index 可选。指定参数的多个值之一。从 1 到 Request.Form(parameter).Count。

示例

示例 1

您可以循环遍历表单请求中的所有值。如果用户通过为颜色元素指定两个值(蓝色和绿色)来填写表单,则可以像这样检索这些值

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

输出

蓝色
绿色

示例 2

考虑以下表单

<form action="submit.asp" method="post">
<p>姓氏: <input name="firstname"></p>
<p>名字: <input name="lastname"></p>
<p>您最喜欢的颜色
<select name="color">
<option>蓝色</option>
<option>绿色</option>
<option>红色</option>
<option>黄色</option>
<option>粉色</option>
</select>
</p>
<p><input type="submit"></p>
</form>

可能会发送以下请求

firstname=John&lastname=Dove&color=Red

现在,我们可以在脚本中使用来自表单的信息: 

您好,<%=Request.Form("firstname")%>。 
您最喜欢的颜色是 <%=Request.Form("color")%>。

输出

您好,John。您最喜欢的颜色是红色。

如果您没有指定要显示的任何元素,例如

表单数据是:<%=Request.Form%> 

输出将如下所示

表单数据是:firstname=John&lastname=Dove&color=Red

❮ 完整 Request 对象参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.