| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1476 人关注过本帖
标题:关于request.form问题(错误:函数需要字符串输入)
只看楼主 加入收藏
51684444
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-5-26
收藏
 问题点数:0 回复次数:4 
关于request.form问题(错误:函数需要字符串输入)
Request 对象, ASP 0102 (0x80004005)
函数需要字符串输入。
/Untitled-5.asp, 第 13 行
我的意思是,在表单上输入年龄和岁数。根据输入表单里年龄和性比来判断输出小妹妹还是小弟弟等


<%
dim sex,age

if request.form (sex)="男" then
if request.form (age<8) then
response.Write("小弟弟")
else
if request.form (age>=8 and age<=15) then
response.Write("小男孩")
else
if request.form(age>=16 and age<=24) then
response.Write("小伙子")
else
if request.form(age>=25 and age<=45) then
response.Write("青年男子")
else
if request.form(age>=46 and age<=55) then
response.Write("中年男子")
else
if request.form(age>=56 and age<=80 )then
response.Write("老爷爷")
else
if request.form(age>80) then
response.Write("老寿星")
end if
end if
end if
end if
end if
end if
end if
else
if request.form (age<8) then
response.Write("小妹妹")
else
if request.form (age>=8 and age<=15) then
response.Write("小女孩")
else
if request.form (age>=16 and age<=24) then
response.Write("小姑娘")
else
if request.form(age>=25 and age<=45) then
response.Write("青年女子")
else
if request.form (age>=46 and age<=55) then
response.Write("中年女子")
else
if request.form(age>=56 and age<=80) then
response.Write("奶奶")
else
if request.form(age>80) then
response.Write("老奶奶")
end if
end if
end if
end if
end if
end if
end if
end if
%>



<form action="" method="post" >
<input name="age" type="text" value="" size="20">请输入内容

<br>
男<input name="sex" type="radio"value="男">
女<input name="sex" type="radio"value="女">
<br>
<input name="" type="submit" value="提交">
</form>
搜索更多相关主题的帖子: form 函数 request 字符 输入 
2008-06-09 18:11
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
<%
dim sex,age

if request.form (sex)="男" then  ' 写法错误。正确写法:if request.form("sex")="男" then
if request.form (age<8) then     ' 写法错误。正确写法:if request.form("age")<8 then
response.Write("小弟弟")

%>

建议你起码看几个别人写的程序,也别光看书,不然印象不深刻。

另外这么多if最好缩进一下,自己看着也清楚。
或者用select case语句:
select case true
  case age<8
       write "小弟弟"
  case age<...
       write ....
   ...
   case else
       write "千年的xx"
end select
2008-06-09 19:05
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
小弟弟  呵呵

[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2008-06-10 11:15
51684444
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-5-26
收藏
得分:0 
多谢二楼的指点。都是网上教程误人子弟。我真该多看看别人代码,我现在才知道IF还能缩进。看来我要学的还多呢
2008-06-10 21:58
ilovey4
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2007-6-21
收藏
得分:0 
LZ多看点书吧

新手!
2008-06-11 02:37
快速回复:关于request.form问题(错误:函数需要字符串输入)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015453 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved