title: Js next previous button from array
body: <p>i have difficulties for displaying value my 'period' variable, i have this form who can be fill in actual by period. this is my form:</p>
  
  <p><a href="http://i.stack.imgur.com/CTjW2.png" rel="nofollow">FORM VIEW SCREEN SHOT</a>  </p>
  
  <p>I just want to activated the button arrow to change value of Week period in array, be the best if how to show today week as a default. :D</p>
  
  <p>This is my sample code:</p>
  
  <h3>FORM.PHP</h3>
  
  <pre><code>  &lt;div class="col-lg-1 col-md-1"  style="text-align:right;"&gt;
      &lt;a id="previous" class="btn btn-primary btn-sm btn-round"&gt;&lt;i class=en-arrow-left8&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/div&gt;
    &lt;div class="slideshow"&gt;
    &lt;div class="col-lg-1 col-md-1" style="text-align:center;"&gt;
      &lt;input id="act4" class=form-control name="act"&gt;
      &lt;span class="help-block text-center" id="demo"&gt;&lt;/span&gt;
      &lt;hr&gt;
      &lt;button type=submit class="btn btn-sm btn-alt btn-primary"&gt;SAVE&lt;/button&gt;
    &lt;/div&gt;
    &lt;div class="col-lg-1 col-md-1"&gt;
      &lt;input id="tgt4" class=form-control value="" disabled&gt;
      &lt;span class="help-block text-center"&gt;&lt;?PHP echo $tdy; ?&gt;&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="col-lg-1 col-md-1"&gt;
      &lt;a id="next" class="btn btn-primary btn-sm btn-round"&gt;&lt;i class=en-arrow-right8&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/div&gt;
  </code></pre>
  
  <h3>Js</h3>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
    var messages = [ { "Week-01" }, { "Week-02" }, { "Week-03" } ];
  
    var messageIndex = 0;
  
    $("#previous").on("click", function(){
      messageIndex = (messageIndex + messages.length -1) % (messages.length);    
      $("demo").text(messages[messageIndex].content);});
  
    $("#next").on("click", function(){
      messageIndex = (messageIndex+1) % (messages.length);    
      $("demo").text(messages[messageIndex].content);});
  
    document.getElementById("demo").innerHTML = messageIndex;
  &lt;/script&gt;
  </code></pre>