Hello,
I am using a for loop in one of my asp page. Could someone let me know if I can do the for loop as follow:
[code]<% for i = 1 to 5 %>
my html code
my html code
my html code
<% Next i %>
instead of
[code]<%
for i = 1 to 5
Response.Write "<input name = 'id'"&i&" type='text' value = "&id& ">"
Next i
%>
That is absolutely fine except in vbscript you don't specify the variable on the next.
should be
Was this answer helpful ?
Yes No
thank for the reply. That works. I do not what I did wrong on my first tried it gave me an error message. In addition, if I want to assign unytsid1, unytsid2,unytsid3,unytsid4,unytsid5 to the value in the following statement, how do I do that ?
Code:
Response.Write "<input name = 'unytsid"&i&"' type='text' value = "&unytsid&i& ">"
thanks
Was this answer helpful ?
Yes No
<%
dim a
a = Array(unytsid1, unytsid2, unytsid3, unytsid4, unytsid5)
for i = 0 to 4
%>
<input type=text name="unytsid<%=i%>" value = "<%=a(i)%>">
<%
next
%>
I think it should work.
[Have provided you the solution, click on the scale icon]
Quote:
| Originally Posted by sunpalozzi thank for the reply. That works. I do not what I did wrong on my first tried it gave me an error message. In addition, if I want to assign unytsid1, unytsid2,unytsid3,unytsid4,unytsid5 to the value in the following statement, how do I do that ?
Code:
Response.Write "<input name = 'unytsid"&i&"' type='text' value = "&unytsid&i& ">"
thanks |
Was this answer helpful ?
Yes No