Reputation: 59
I'm trying to make a Countdown Page, it shall show each counted number, it takes the numbers from a user entry, inside a table.
In the end it shall show for example from 10 to 1, the numbers 10,9,8,7,6,5,4,3,2,1.
Meanwhile i get Results, but only for counting up, but how do i get it to count down, it goes into my loop but it shows only the first Number, how do i display the rest?
<%
response.flush
l_start = request.querystring("f_start")
l_goal = request.querystring("f_goal")
%>
<form action = "countdown.asp" method = "get">
<h1 align = "center">Dies ist ein Zähler!<h1>
<table border = "1" align = "center">
<tr>
<td>
Bitte einen Startwert eingeben.
</td>
<td>
<input type = "number" name = "f_start" value = "<%=l_start%>"
</td>
<td width = "100">
</td>
<td>
Bitte einen Zielwert eingeben.
</td>
<td>
<input type = "number" name = "f_goal" value = "<%=l_goal%>"
</td>
<td>
<input type = "submit" value = "Go!" \>
</td>
</tr>
<tr>
<td>
Gezählte Zahlen:
</td>
<td>
<%
if request.querystring(("f_start")) < request.querystring(("f_goal")) then
For i = l_start To l_goal
response.write("" & i & ",")
Next
else
counter = l_start
while counter > l_goal
response.write(counter)
response.write(",")
counter = l_start - 1
wend
end if
%>
</td>
</tr>
</table>
</form>
Upvotes: 1
Views: 191
Reputation: 3297
There are a number of things wrong here. First, you only go into the then
clause of the if
statement if f_start
is greater then f_goal
, then you only go into the body of the while
if f_start
is less than or equal to f_goal
. The conditions are similar for the else
clause.
But it's worse than that because you use variables called f_start
, f_goal
and f_count
that aren't defined. I think you intend to use values from Request.QueryString
, but that's not what you're doing.
You assign values to l_start
, l_goal
and l_count
but never change them. You modify the values in x
and y
but never use them. You put the unchanged l_start
and l_goal
back into the form.
Finally, there appears to be a cognitive disconnect in your understanding of where this code executes and how the variables in the script are related to the form. This is executing on the server. The values you enter in the form get submitted to the server. The script runs and does not do anything with the values passed to it from the form. It then puts those values right back onto the form.
Upvotes: 1