title: How do I write a looping link generator with a memory?
body: <p>I have this code where a link is presented based on a random function. I want to be able to change this to where this isn't random and I can walk through the links with a loop function with i++ and where he remembers where he left even if the site is left and there is a new visitor. For example: Visitor x clicks on the link and is redirected to link1 and a day later visitor y visits clicks on the link and is redirected to link2 and so on. When the loop is at the last link, in this case link 3, he needs to start at 1 again. I have no clue where to begin with this and wondered if you guys have any thoughts on this.</p>
  
  <p>Cheers :)</p>
  
  <pre><code>&lt;script type="text/javascript'&gt;
      function links_3(){
          var mylink=Math.round(Math.random()*2)
          var link1="http://www.test1.com"
          var link2="http://www.test2.com"
          var link3="http://www.test3.com"
          if (mylink==0)
              window.location=link1
          else if (mylink==1)
              window.location=link2
          else if (mylink==2)
              window.location=link3
      }
  &lt;/script&gt;
  &lt;form&gt;
      &lt;input type="button" value="link!" onClick="links_3()"&gt;
  &lt;/form&gt;
  </code></pre>