Hey all,
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 value which is been clicked.
Here is my code:
$(document).ready(function() {
var link = $('a[id]').size();
//alert(link);
var i=1;
while (i<=link)
{
$('#payment_'+i).click(function(){
//alert($("#pro_path_"+i).val());
$.post("<?php echo $base; ?>form/setpropath/", {pro_path: $("#pro_path_"+i).val()}, function(data){
//alert(data);
$("#container").html(data);
});
});
i++;
}
});
Here the placement_1
, placement_2
.... are the href
s and the pro_path
is the value I want to post, the value is defined in the hidden input type with id as pro_path_1
, pro_path_2
, etc. and here the href
s varies for different users so in the code I have $('a[id]').size()
. 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.
I think onready
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.
Thanks, all