0

I have an external JS file that holds variables, for example: numberToLevel.js

var number = 1;

And very simply through HTML I want to check the value and change it as the user goes through the navigation.

<script type="text/javascript" src="js/numberToLevel.js"></script>
    <script>
        if(number == 1){
            alert('Success!! ' + number);
        }
        number = number + 1;
    </script>

However, the value of number doesn't seem to change. the alert is triggered and it does display what it should. However, in the next page I needed it to be 2 instead of 1 and that hasn't happened.

Can anyone please help me?

jPratas
  • 225
  • 1
  • 6
  • 17
  • You need to load the script as you load a new page usually. You probably need a cookie or localstorage (or sessionstorage as well.) – zer00ne Aug 14 '16 at 15:02
  • You have included the JavaScript script in your HTML, right? Also `localStorage` is something you'd want to consider. – Script47 Aug 14 '16 at 15:02

0 Answers0