# How to change Variable

**URL:** <https://forum.kirupa.com/t/how-to-change-variable/303777>\
**Category:** Uncategorized\
**Created:** [January 26, 2010, 10:27pm UTC](https://forum.kirupa.com/t/how-to-change-variable/303777 "2010-01-26T22:27:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandman79x](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sandman79x](https://forum.kirupa.com/u/Sandman79x)\
**Post date:** [January 26, 2010, 10:27pm UTC](https://forum.kirupa.com/t/how-to-change-variable/303777/1 "2010-01-26T22:27:06Z")

</div>

How can i get a variable to change based off of a function? for instance.

var imageNumber = 1;

and when i click on the next button it kicks off roughly this function.

imageNumber ++;

effectively adding to the image number.

but it is confined only to that function.

the imageNumber outside of that function didnt change.

how can i get the next button to change the number outside of the function?
