Print the value in loop in Jquery ready function
<p>somehow still not able to do what I’m inted to do. It gives me the last value in loop on click not sure why. Here I want the <strong>value which is been clicked</strong>.</p>

<p>Here is my code:</p>

<pre><code>$(document).ready(function() {
  var link = $('a[id]').size();
  //alert(link);
  var i=1;
  while (i&lt;=link)
   {
 $('#payment_'+i).click(function(){
   //alert($("#pro_path_"+i).val());
  $.post("&lt;?php echo $base; ?&gt;form/setpropath/", {pro_path: $("#pro_path_"+i).val()}, function(data){ 
   //alert(data);
   $("#container").html(data);    
  });
 });
 i++;
   }
});
</code></pre>

<p>Here the <code>placement_1</code>, <code>placement_2</code> .... are the <code>href</code>s and the <code>pro_path</code> is the value I want to post, the value is defined in the hidden input type with id as <code>pro_path_1</code>, <code>pro_path_2</code>, etc. and here the <code>href</code>s varies for different users so in the code I have <code>$('a[id]').size()</code>. Somehow when execute and alert I get last value in the loop and I don’t want that, it should be that value which is clicked.</p>

<p>I think <code>onready</code> event it should have parsed the document and the values inside the loop
I’m not sure where I went wrong. Please help me to get my intended result.</p>

<p>Thanks, all</p>
