# Please help me loop images

**URL:** <https://forum.kirupa.com/t/please-help-me-loop-images/188452>\
**Category:** Uncategorized\
**Created:** [May 8, 2006, 3:59am UTC](https://forum.kirupa.com/t/please-help-me-loop-images/188452 "2006-05-08T03:59:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blacey777](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@blacey777](https://forum.kirupa.com/u/blacey777)\
**Post date:** [May 8, 2006, 3:59am UTC](https://forum.kirupa.com/t/please-help-me-loop-images/188452/1 "2006-05-08T03:59:34Z")

</div>

I know that this is probably very dumb question, but I need to combine the following two codes in order to get my images to loop when “next” and “previous” buttons are pushed. I’ve tried several combinations and its just not working. I would really appreciate it if anyone could help me!!!

// code #1//

function nextImage()

{

```
if (p &lt;= (6 - 1))

{

	

	p++;

	

	eval("button" + p).onPress();

}

```

}

//code #2//

function nextImage()

{

```
p++;

if (p &gt; 6)

{

	p = 0;

	eval("button" + p).onPress();

}

```

}
