title: Javascript var change when reload page
body: <p>I have a string array in javascript. But when I use href='mypage.php?id=var', I lost this array. I need keep it out for use it in the $_GET. This is the code:</p>
  
  <pre><code>&lt;script&gt;
  
  var element_selected=[];
  var i = 0;
  
  function hrefPage()
  {
      var pagina = "index.php?id=renew";
      location.href = pagina;
  }
  
  function loadArray(value)
  {
      element_selected[i] = value;
      i++;
  }
  
  &lt;/script&gt;
  
  &lt;?php
  
  if(isset($_GET['id']))
  {
      if ($_GET['id'] == "renew")
      {
          $selected_elements = array();
          $j = 0;
          for($j = 0; $j &lt; "&lt;script&gt; document.write(i) &lt;/script&gt;"; $j++)
          {
              $selected_elements[j] = "&lt;script&gt; document.write(elements_selected[j]) &lt;/script&gt;";
              echo $selected_elements[j];
          }
      }
  }
  
  ?&gt;
  </code></pre>