当前位置:编程学习 > asp >>

ASP新手的问题

下面是我写的一段处理表单数据的代码,运行后提示错误如下:

错误类型:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象: 'name'
/getdata.asp, 第 9 行

该怎样修改代码,才会没有这样的错误。

代码源程序:
<%
name=Trim(request.form("name"))
password=Trim(request.form("password"))
yzm=Trim(request.form("yanzhengma"))
checkcode=Trim(Session("verifycode"))
pass="123456"

i=1
c=name.Chars(i)
response.Write(c)

if name<>"user" and name<>"test" then
response.Write("Sorry!This user doesn't exist!")
elseif password<>pass then
response.Write("密码错误!")
elseif yzm<>checkcode then
response.Write("验证码错误!")
else
response.Write("尊敬的")
response.Write(name)
response.Write(",恭喜您成功登录<font color=red>湖南师范大学学生管理系统</font>!")
response.Write("<br>")
end if
response.Write(checkcode)
%>
补充:chars(integer)从字符串中取得第integer个字符,chars(interger)是System.String类的方法。
		
答案:
最佳答案:

问题所在:c=name.Chars(i)

ASP中没有这样的写法,如果是截取字符的话,可以这样写

c=left(name,4)'截取name前面的4个字符,left函数可查看vbs手册,上面有更详细的解释。
Chars(i)
在哪?
c=name.Chars(i)中name已经装相到c了,而输出后的对象名称还是name, c 到哪去了?
1.有可能在提交页面传入了空字符串
2.提交页面的form中,输入name字段的控件id值不正确

上一个:vbscript html 转换 asp
下一个:请教一个ASP调用问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,