0

我对 HTML 和 asp 编程相当陌生,我遇到了以下问题:

当我创建一个带有提交按钮(来自教程)和 .asp 脚本来处理该提交的简单 HTML 页面时,我只是获取 .asp 脚本本身,而不是我提交的文本。

编码:

HTML 代码:

<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>

ASP 代码:

<%@ Language="VBScript" %>
<html>
<head>
<title>Submitted data</title>
</head>

<body>
<%
Dim name
name=Request.Form("name")
Response.Write("Name: " & name & "<br>")
%> 
</body>
</html>

有谁知道问题是什么?

谢谢!

4

1 回答 1

0

请尝试以下代码

<html>
<body>
<form name="input" action="html_form_action.asp" method="post">
Username: <input type="text" id="user" name="user">
<input type="submit" value="Submit">
</form>
</body>
</html>

文件名:html_form_action.asp

<%@ Language="VBScript" %>
<html>
<head>
<title>Submitted data</title>
</head>

<body>
<%
Dim name
name=Request.Form("user")
Response.Write("Name: " & name & "<br>")
%> 
</body>
</html>
  1. 我将表单方法从 get 更改为 post
  2. 将 Request.Form("name") 更改为 Request.Form("user") 因为输入文本名称是 user

希望能帮助到你

于 2013-07-26T05:10:50.283 回答