Hi there, I've just started using ASP with VBscript and have come up with what seems like a completely simple problem - yet i am unable to solve it.
When I type the following in and store it as xv.asp, I believe I should get a web page where I can increase or decrease the value of x between 0 and 10. Yet, when I run it, and press either 'increase' or 'decrease' it jumps straight to 10 and stays there. I guess the problem is with the last 'If...Then' but can't see it.
HTML Code:
<html>
<head></head>
<body>
<%
Dim x, r, little, big
little=1
big=10
r=Request.Form("xval")
If (Not Isnumeric(r)) Then
x=5
Else
x=r
End If
If x <= little Then
x=little
ElseIf x >= big Then
x=big
End If
Response.Write("x = " & x & " r = " & r)
%>
<br>
<form action="xv.asp" method=post>
<input name="xval" value="<%=x-1%>" type="hidden"><input type="submit" value="Decrease x"></form>
<form action="xv.asp" method=post>
<input name="xval" value="<%=x+1%>" type="hidden"><input type="submit" value="Increase x"></form>
<form action="xv.asp" method=post>
<input name="xval" value="boo" type="hidden"><input type="submit" value="Reset x"></form>
</body>
</html>
Any suggestions? I have consulted 3 ASP/VBScript books already and can't see where i'm going wrong. It seems to work if i change the 'little' and 'big' and hardcode the values 1 and 10 in instead, but that isn't practical on my site.
Sorry for being so dumb; but i did manage to do the rest of the site ok, including setting up database access through ASP.
Thanks.
|