Home > ASP Development > for loop

for loop



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
%>

    
Guest


That is absolutely fine except in vbscript you don't specify the variable on the next.


Code:


 <% next i %>
 




should be


Code:


 <% next %>
 



Was this answer helpful ? Yes No   
Guest


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   
Guest


<%
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   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved