title: How can i do to get multiple value on multiple input fields?
body: <p>I have inputbox like this:</p>
  
  <pre><code>&lt;input type="text" id="namecity1"  name="city1" /&gt;
  &lt;input type="hidden" id="idcity1" name="idcity1" /&gt;
  
  &lt;input type="text" id="namecity2"  name="city2" /&gt;
  &lt;input type="hidden" id="idcity2" name="idcity2" /&gt;
  </code></pre>
  
  <p>script:</p>
  
  <pre><code>&lt;script src="jquery-1.4.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="jquery.autocomplete.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" /&gt;
  
  &lt;script&gt;
  $(function() 
  {
  var city;
  var idcity;
  
  for(var i=1;i&lt;=2;i++)
  {
    city = "namecity"+i;  
    idcity= $("#"+city).next().attr('id');    
  
   $("#"+city).autocomplete("states.php").result(function(event, data, formatted) 
   {
     $("#"+idcity).val(data[1]);
   });
  }//for    
  });
  &lt;/script&gt; 
  </code></pre>
  
  <p>Variable <code>i</code> after :</p>
  
  <pre><code>result(function(event, data, formatted)
  </code></pre>
  
  <p>Why is it not 1,2 as a function <code>for</code> the above?</p>