各位兄弟姐妹们:以下是一个简单的在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>

解决方案 »

  1.   

    可以用,但是不能用服务器控件了,如Response,Rrequest等
      

  2.   

    谢谢kkun_3yue3(嘟啊嘟啊嘟啊嘟)及wisest(无影无忠) 。但我试着把这段代码存为.aspx也执行不了....郁闷中
      

  3.   

    你这个vbscript脚本中的语句,本身就不是vbscript,而是后台语句。
    所以这些语句是要写到后台代码中去的。
    你可以先去看看asp  或asp.net的书。
      

  4.   

    不好意思,的确是我糊涂了。如果在客户端执行的vbscript,用windows.alert弹出提示消息是可以的吧?不过有点奇怪有些浏览器为什么没有响应?是不是因为设置的问题?
    <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>
      

  5.   

    我不懂vbscript,不过你的程序肯定不会运行的。当if user.value<>"" 运行的时候,user这个元素还没有出现呢。
    另外,建议不要学习vbscript,毕竟别的浏览器不兼容vbscript,学javascript.