$(document).ready(function() {
$('table#example').on('keyup', '#quantity', function(){
var fiyat = $(this).attr('data-id');
var f = parseInt($(this).val());
if (!isNaN(f) && f>0) {
$(this).closest('tr').addClass('secili');
} else {
$(this).closest('tr').removeClass('secili');
}
hesapla();
});
function post() {
var x = new Array();
$('table#example .secili').each(function(){
var f = parseInt($(this).find('td').eq(0).find('input').val());
if (!isNaN(f) && f>0) {
x.push(new Array(
$.trim($(this).find('td').eq(1).html()),
f,
$.trim($(this).find('td').eq(4).html())
));
}
});
alert(JSON.stringify(x));
}
$('#sub').bind('click',function(){post()});
function hesapla() {
toplam = 0;
$('table#example .secili').each(function(){
var f = $(this).find('td').eq(4).html();
var f1 = f.replace("$","");
var f2 = f1.replace(".", "");
f2 = parseInt(f2);
var adet = $(this).find('input').eq(0).val();
var ucret = f2 * parseInt(adet);
toplam = toplam + ucret;
var nm = numeral(toplam).format('$0,0.00').toString();
$("#sub").html(nm);
});
}
});toggleClass olayınıda düzelttim. orda hata var.
post() fonksiyonu çalıştırın.
$('#sub').bind('click',function(){post()});
test için <p id="sub"></p> üzerine tıklayın.
misal [["A1000.H",2,"$6.560,00"],["A2000.L",3,"$3.560,00"]] gibi bir json sonucu vericek. bu veriyide istediğin sayfaya post gönderebilirsin.