初学者请教一个ASP的问题

来源:百度知道 编辑:UC知道 时间:2024/06/27 10:24:43
有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=0,1,2,3时,均有btnValue(i)=Request("btni"),那四个IF语句:
<%
If btnValue(0)=Request("btn0") Then
Msg="你按了"&苍蝇&"钮"
ElseIf btnValue(1)=Request("btn

因为上面的数组Array("苍蝇","豆娘","毛毛虫","蛾")
已经将位置指定了`~如:苍蝇(0),豆娘(1)......

下面的IF中btnValue(i)=Request("btni")中的i就是根据上面的数组位置指定的`~