Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping and Lists 1

Status
Not open for further replies.

ryan

Programmer
Nov 13, 2000
73
US
ok ... here's my problem. I can't seem how to create a list of strings in asp and then loop through them. In ColdFusion it's pretty simple you define your list:

<cfset teststring=&quot;1,2,3,4,5&quot;>

and then you can loop through it via this:

<cfloop index=&quot;currentnum&quot; list=&quot;teststring&quot; delimiter=&quot;,&quot;>
my current number is #currennum#
</cfloop>

HOW DO I DO THIS IN ASP ... ARG THIS IS KILLING ME. THANKS GUYS!
 
> In ColdFusion it's pretty simple you define your list:

Well now it's all pretty simple when you know how to do it then isn't it? Developing web pages isn't exactly &quot;rocket surgery&quot;.

<%
var myStrings = new Array(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;);
for(j=0; j<myStrings.length; j++)
Response.Write(&quot;my current number is &quot; + myStrings[j] + &quot;<br>&quot;);

// now that was fun... lets do it again
var myStr = &quot;1,2,3,4&quot;;
myStrings = myStr.split(&quot;,&quot;);

for(j=0; j<myStrings.length; j++){
%>
my current number is <%=myStrings[j]%><br>
<%} %>

To people with language backgrounds like C/C++ and Java that would be much more readable than the Cold Confusion equivalent.

&quot;But, that's just my opinion... I could be wrong&quot;.
-pete
 
Yes your right. I didn't mean to be a smart. Thanks, I really appreciate your help pete ... your great!

Ryan
 
Oops I responded too soon. How can I do this in ASP. I need to take a string not an array and then split it up. How?

Ryan
 
Nevermind I figured it out by doing split(expression,delimiter)

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top