各位兄弟姐妹们:以下是一个简单的在text框输入用户名,然后通过vbscript脚本语言显示你好+用户名。但为什么运行时总提示“缺少对象request”呢?另外,这个文件我是存为html格式的。请问:html文件里可以嵌入vbscript脚本吗?谢谢
<html>
<head>
<title>表单的例子</title>
</head>
<body>
<form method="post" action="a.htm" >
<table align="center" >
<tr>
<td>用户名:</td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td><input type="submit" value="注册" ></td>
<td><input type="reset" value="重写"> </td>
</tr>
</table>
</form>
<p>
<script language="VBScript">
if request.form("user")<>""then
a=request.form("user")
response.write("你好"+a)
end if
</script>
</p>
</body>
</html>
<html>
<head>
<title>表单的例子</title>
</head>
<body>
<form method="post" action="a.htm" >
<table align="center" >
<tr>
<td>用户名:</td>
<td><input type="text" name="user"></td>
</tr>
<tr>
<td><input type="submit" value="注册" ></td>
<td><input type="reset" value="重写"> </td>
</tr>
</table>
</form>
<p>
<script language="VBScript">
if request.form("user")<>""then
a=request.form("user")
response.write("你好"+a)
end if
</script>
</p>
</body>
</html>
所以这些语句是要写到后台代码中去的。
你可以先去看看asp 或asp.net的书。
<html>
<head><title>表单的例子
<script language="vbscript">
if user.value<>"" then
windows.alert("你好"+user.value)
end if
</script> </title></head>
<body>
<form method=post action="form.htm" >
<table align="center" >
<tr><td colspan=2 align="center">用户注册</td></tr>
<tr>
<td>呢称:</td>
<td><input type="text" name="user"></td>
</tr>
</table>
</form>
<body>
</html>
另外,建议不要学习vbscript,毕竟别的浏览器不兼容vbscript,学javascript.