title: javascript advance number onclick or on reload
body: <p>I display a random DIV every time my webpage is reloaded using a simple function. This produces too many repeats because I only have seven divs.  </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              randomNumber = Math.floor(Math.random()*7+1);  
              window.onload = function() {
                 if (randomNumber == 1) {
                    document.getElementById("n1").style.display = "inline";
                 }
                 if (randomNumber == 2) {
                    document.getElementById("n2").style.display = "inline";
                 }
        ...[ETC. through 7]
       }
              }
      &lt;/script&gt;
  </code></pre>
  
  <p>I would like to solve this by replacing the "random number" with a predictable "progressing number".  Can I advance a variable with every reload or onclick and execute the function to display each DIV in sequence? 1,2,3... displaying all seven divs before repeating.</p>
  
  <p>I worry I would need cookies to do this with each individual visitor.  Because the traffic is very low (likely one visitor at a time), perhaps I could use code from a page counter to achieve this.  </p>
  
  <p>I searched for any examples of this in action but found none.  I would be very appreciative of any and all suggestions.  Thanks for your time.</p>