# Whats wrong with these loops?

**URL:** <https://forum.kirupa.com/t/whats-wrong-with-these-loops/217842>\
**Category:** flash\
**Created:** [March 2, 2007, 11:07am UTC](https://forum.kirupa.com/t/whats-wrong-with-these-loops/217842 "2007-03-02T11:07:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimjiminyjimjim](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jimjiminyjimjim](https://forum.kirupa.com/u/jimjiminyjimjim)\
**Post date:** [March 2, 2007, 11:07am UTC](https://forum.kirupa.com/t/whats-wrong-with-these-loops/217842/1 "2007-03-02T11:07:48Z")

</div>

I have some code that seems to have a problem. I can’t seem to pass the x variable from one loop to within another loop.

```auto

var myLv = new LoadVars();
var myNv = new LoadVars();

	
myLv.sendAndLoad("buynowmodels.php", myLv, "POST");
myLv.onLoad = function(success)
	{

		displayprices();
	}

function displayprices() {
	
	for(x=0;x<myLv.n;x++) {
		
			new_mc = priceList.attachMovie("price_slot", "mc_"+x, x);
			new_mc.modelName.text = myLv["modelname"+(x)];
			new_mc._y = (150*x);
			
			
			myNv.sendAndLoad("buynowread.php", myNv, "POST");
			
			myNv.onLoad = function(success) {
			
			for(p=0;p<myNv.n;p++) {
			
			new_price= _root.priceList["mc_"+x].listContainer.attachMovie("list_item1", "price_"+p, p);
			new_price._y = (25*p);
			
		
			}
			}
		
			

		}
	}

```

Everything works fine if you change this line with x in it:

```auto

new_price= _root.priceList["mc_"+x].listContainer.attachMovie("list_item1", "price_"+p, p);

```

to this with an integer

```auto

new_price= _root.priceList["mc_"+1].listContainer.attachMovie("list_item1", "price_"+p, p);

```

but I want it to happen for all values of x not just one movie clip.

Any help would be much appreciated.

Thank you.
