# Help with navigation logic

**URL:** <https://forum.kirupa.com/t/help-with-navigation-logic/285808>\
**Category:** Uncategorized\
**Created:** [April 6, 2009, 8:14pm UTC](https://forum.kirupa.com/t/help-with-navigation-logic/285808 "2009-04-06T20:14:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deborah](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Deborah](https://forum.kirupa.com/u/Deborah)\
**Post date:** [April 6, 2009, 8:14pm UTC](https://forum.kirupa.com/t/help-with-navigation-logic/285808/1 "2009-04-06T20:14:50Z")

</div>

Hi,

I am trying to dynamically assign “next” and “back” values to my buttons. I have 2 arrays; Next is empty, Back has “step1” in it.

When a user makes their selection, say a,b,c or d from step1. That value is pushed into the Next array.

next.push(value);

They then make a selection from this page, say, e,f,g or h. Now, the new value is pushed into next and the old value is pushed into back. eg

back.push(next.pop());  
next.push(newValue);

if a user clicks on Back, the value is retrieved from the array, then popped.

gotoAndStop(back.pop());

This goes on for 3 more steps (pending on their selections).

The problem is, if they select say a on step 1 but change their mind and select b before hitting Next, both values are pushed into the next array.

Just from writing this I see I should move the array.push to the next function but I am wondering if anyone has any better suggestions.

Help or suggestions are appreciated.

Deborah
