加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP对表单和用户输入的处理

发布时间:2023-09-15 10:23:08 所属栏目:Asp教程 来源:
导读:在ASP中,你可通过VBScript和其他方式调用自程序。

实例:
使用method="get"的表单

如何使用Request.QueryString命令与用户进行交互。

以下为引用的内容:
<html>
<body>
<form action="/example/aspe/
在ASP中,你可通过VBScript和其他方式调用自程序。

实例:
使用method="get"的表单

如何使用Request.QueryString命令与用户进行交互。

以下为引用的内容:
<html>
<body>
<form action="/example/aspe/demo_aspe_reqquery.asp" method="get">
Your name: <input type="text" name="fname" size="20" />
<input type="submit" value="Submit" />
</form>
<%
dim fname
fname=Request.QueryString("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>

使用method="post"的表单

如何使用Request.Form命令与用户进行交互。

以下为引用的内容:
<html>
<body>
<form action="/example/aspe/demo_aspe_simpleform.asp" method="post">
Your name: <input type="text" name="fname" size="20" />
<input type="submit" value="Submit" />
</form>
<%
dim fname
fname=Request.Form("fname")
If fname<>"" Then
Response.Write("Hello " & fname & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>

使用单选按钮的表单

如何使用Request.Form通过单选按钮与用户进行交互。

以下为引用的内容:
<html>
<%
dim cars
cars=Request.Form("cars")
%>
<body>
<form action="/example/aspe/demo_aspe_radiob.asp" method="post">
<p>Please select your favorite car:</p>
<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br />
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br />
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input>
<br /><br />
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>

如果用户数据会输入到数据库中,那么你应该考虑使用服务器端的验证。有一种在服务器端验证表单的好的方式,就是将(验证过的)表单传回(post)表单页面,而不是转至不同的页面。用户随后就可以在同一个页面中得到错误信息了。这样做的话,用户就更容易发现错误了。

 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章