title: How to set the permanent value of variable in javascript/jQuery?
body: <p>I'm creating a jquery ui sortable with cookies to maintain the state when updated.
  <br>Here's the important part of the code:</p>
  
  <pre><code>for(i=0; i&lt;counter; i++) {
      var connect = "";
      var count = 0;
      var tipo = "tipo" + i;
      for(j=0; j&lt;counter; j++) {
          if(j != i) {
              if(count &gt; 0) {
                  connect = connect + ",.tipo" + j;
              }
              else {
                  connect = ".tipo" + j;
                  count++;
              }
          }
      }
  
      $( "." + tipo ).sortable({
          connectWith: connect,
          dropOnEmpty: "true",
          opacity: 0.8
      });
  
      $(".tipo" + i).sortable({
          activate: function(event, ui) {
              var order = $( "." + tipo ).sortable('toArray');
              createCookie(tipo, order, 1);
          },
          update: function(event, ui) {
              var order = $( "." + tipo ).sortable('toArray');
              createCookie(tipo, order, 1);
          },
          receive: function(event, ui) {
              var order = $( "." + tipo ).sortable('toArray');
              createCookie(tipo, order, 1);
          }
      });
  
  }
  </code></pre>
  
  <p><br>
  The problem that I've is that <code>var tipo = "tipo" + i;</code> will become <code>tipo2</code> in the last statement and all of the previous <code>createCookie(tipo, order, 1);</code> will have <code>tipo</code> as <code>tipo2</code> instead of <code>tipo0</code> or <code>tipo1</code>.</p>
  
  <p>I hope you understand what I'm saying. If not, just tell me!</p>
  
  <p>But, how can I make this have the right <code>tipo</code>?</p>