# Looping through data

**URL:** <https://forum.kirupa.com/t/looping-through-data/4630>\
**Category:** flash\
**Created:** [August 14, 2002, 9:29pm UTC](https://forum.kirupa.com/t/looping-through-data/4630 "2002-08-14T21:29:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerium](https://avatars.discourse-cdn.com/v4/letter/z/85e7bf/32.png) [@zerium](https://forum.kirupa.com/u/zerium)\
**Post date:** [August 14, 2002, 9:29pm UTC](https://forum.kirupa.com/t/looping-through-data/4630/1 "2002-08-14T21:29:48Z")

</div>

Ok I have a question… no idea how complicated this is but here goes:

I have the following script for looping through data that is being returned into flash through a coldfusion page. Page just spits out my variables ie: Summary1=Bill,Summary2=Bob

for (i=1; i\<=1; ++i){  
&nbsp&nbsp&nbspvar returned = search[“Summary” +i];  
&nbsp&nbsp&nbsptrace(returned);  
&nbsp&nbsp&nbsp\_root.results.text = “Results for your search '” +myData+ “’:” +returned;   
}

I have this loop written to process the data and display it in a text area (its a search program).

Now what is happening is that as soon as flash gets goes through this loop it overwrites the first variable, bill and only displays bob. How would i go about displaying both Bill and Bob in the text area?

thanks,

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2002, 9:47pm UTC](https://forum.kirupa.com/t/looping-through-data/4630/2 "2002-08-14T21:47:56Z")

</div>

```auto
for (i=0; i<=1; ++i){
	var returned = search["Summary" +i];
	trace(returned);
	_root.results.text = "Results for your search '" +myData+ "':" +returned;	
}

```

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2002, 10:43pm UTC](https://forum.kirupa.com/t/looping-through-data/4630/3 "2002-08-14T22:43:22Z")

</div>

well what I’m really trying to do would look more like this:

for (i=1; i\<=5; ++i){  
&nbsp&nbsp&nbspvar returned = returned+"-"+search[“Summary” +i];  
&nbsp&nbsp&nbsptrace(returned)   
}  
\_root.results.text = “Results for your search '” +myData+ “’:” +returned;

i almost have it working except i dont know how to throw a break in there so the “-” is holding the place for the break.

also I would like to set the 5 to a variable instead of a static number. Any ideas?

-z

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2002, 11:03pm UTC](https://forum.kirupa.com/t/looping-through-data/4630/4 "2002-08-14T23:03:55Z")

</div>

Try

```auto
for (i=0; i<=5; ++i){
	var returned = search["Summary" +i];
	trace(returned);
	_root.results.text += "Results for your search '" +myData+ "':" +returned;	
}

```

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2002, 11:43pm UTC](https://forum.kirupa.com/t/looping-through-data/4630/5 "2002-08-14T23:43:24Z")

</div>

That works except for one problem. When the loop executes it updates \_root.results.text 5 seprate times and you only get to view the 5th rendering of the code.

with the way that I have done it above it shows up correctly but I would like to insert hard returns instead of the “-” character.

I would also like to setup a variable for the number “5” in “i\<=5” but, I know how to do that. **How do i tell flash to do a hard return?**

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 15, 2002, 12:41am UTC](https://forum.kirupa.com/t/looping-through-data/4630/6 "2002-08-15T00:41:17Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 15, 2002, 2:53am UTC](https://forum.kirupa.com/t/looping-through-data/4630/7 "2002-08-15T02:53:04Z")

</div>

thanks,

one of our coldfusion programmers mentioned that too but, didn’t try it yet. I’ll give it a shot.

-z
