function findPrice(id) { var dim = $('#dimension').val(); if($('#cover')) var cover = $('#cover').val(); var ct = $('#count').val(); $.ajax({ type: 'POST', data: {dimension: dim, count: ct, cover:cover}, url: 'http://www.albumfotograficzny.com.pl/index.php/pl/get_price/'+id, success: (function (data) { $('#price').text(data); }) }); } $(document).ready(function() { $('.pricelist').change(function(e){ var o = e.target; var id = o.id.split('_'); var count = $('#count_'+id[1]); var cover = $('#cover_'+id[1]); if (count) count = count.val(); else count = ''; if (cover) cover = cover.val() else cover = ''; pricelist_price(id[1], count, cover); }); }); function pricelist_price(id, count, cover) { //cover = $.URLEncode(cover); $.ajax({ type: 'POST', dataType: "json", data: {count: count, cover: cover}, url: 'http://www.albumfotograficzny.com.pl/index.php/pl/get_pricelist_price/'+id,//+'/'+count+'/'+cover, success: (function (data) { $.each(data.dimensions, function(k,v) { //k = k.split('_')[1]; $('#price_'+id+k).text(v+' zł'); }); }), error: (function (data, e, o) { alert(e); }) }); }