ChefSausage
Programmer
I have a For...Next loop around some HTML code for output, and just before the response.write line, I have an If condition to alter the output for one variable when the condition is met.
totalpages = 48, maxpage = 5 (just for your reference)
<%
startPage = 1
endPage = startPage + (maxPage - 1)
For i = 1 to totalpages %>
<option value="<%=i%>">
<%If endPage = totalpages Then
endPage = totalpages
End If
response.write("(" & startPage & "-" & endPage & ""%> </option>
<%
startpage = startPage + 1
endPage = endPage + 1
Next
%>
The problem I'm having is each loop outputs startpage and endpage in a dropdown; the latter var being 4 higher than the former (ex: 1-5,2-6,3-7,etc). When endpage hits the value of 48 I want it to stop looping and only display 48. That is what the If condition is for. But, ASP is completely ignoring that If statement and continually loops, all the way up to 52. Am I missing something obvious b/c it seems very straight forward.
totalpages = 48, maxpage = 5 (just for your reference)
<%
startPage = 1
endPage = startPage + (maxPage - 1)
For i = 1 to totalpages %>
<option value="<%=i%>">
<%If endPage = totalpages Then
endPage = totalpages
End If
response.write("(" & startPage & "-" & endPage & ""%> </option>
<%
startpage = startPage + 1
endPage = endPage + 1
Next
%>
The problem I'm having is each loop outputs startpage and endpage in a dropdown; the latter var being 4 higher than the former (ex: 1-5,2-6,3-7,etc). When endpage hits the value of 48 I want it to stop looping and only display 48. That is what the If condition is for. But, ASP is completely ignoring that If statement and continually loops, all the way up to 52. Am I missing something obvious b/c it seems very straight forward.