初学者请教一个ASP按钮的问题

来源:百度知道 编辑:UC知道 时间:2024/05/23 23:14:35
有btn0~btn3的4个按钮
<%
btnValue=Array("苍蝇","豆娘","毛毛虫","蛾")
For i=0 To UBound(btnValue)
Response.Write"<input type=submit name=btn"&i&_
"value="&btnValue(i)&">"
Next
%>

<%
If btnValue(0)=Request("btn0") Then
Msg="你按了"&苍蝇&"钮"
ElseIf btnValue(1)=Request("btn1") Then
Msg="你按了"&豆娘&"钮"
ElseIf btnValue(2)=Request("btn2") Then
Msg="你按了"&毛毛虫&"钮"
ElseIf btnValue(3)=Request("btn3") Then
Msg="你按了"&蛾&"钮"
End If
%>
我想请问一下为什么btnValue(i)=Request("btni")可以判断哪个键按下了呢,如果没有按下i键,那么Request('btni)返回的是个什么值呢?谢谢!
我想问如果我按的是i+1号键,那Request(”btni”)返回的是空值吗?

request是取页面传送值的函数,没按Request('btni)应该为空。

"<input type=submit name=btn"&i&"value="&btnValue(i)&">"
其实就是
"<input type=submit name=btn"&i&"value="&btnValue(1)&">"
"<input type=submit name=btn"&i&"value="&btnValue(2)&">"
"<input type=submit name=btn"&i&"value="&btnValue(3)&">"
"<input type=submit name=btn"&i&"value="&btnValue(4)&">"

不近你按不按,他都不会变的

他只需判断你按的是哪一个就行了。

比哪你按的是

"<input type=submit name=btn"&i&"value="&btnValue(2)&">"
这个键又触发了这个
ElseIf btnValue(2)=Request("btn2") Then
Msg="你按了"&毛毛虫&"钮"

那么就会显示"你按了"&毛毛虫&"钮"