igor.morgunov,
$(function() {
var discount = $(".discount");
discount.change(function() {
var len = discount.filter(":checked").length;
var result = [15000, 6000, 6000].slice(0,len);
result.push(0,0,0)
result.length = 3;
price.forEach(function(el) {
[].splice.apply(el, [1,3].concat(result))
})
})
});
var price = [
[0, 0, 0, 0, 0, 5000],
[0, 0, 0, 0, 0, 5000],
[0, 0, 0, 0, 0, 5000]
];
function calculate() {
var sum = 0;
var i = $('.btn.active').find('input:radio[name="options"]').val();
console.log('i = ' + i);
console.log('j = ' + j);
for (var j = 0; j < 6; j++) {
if ($('#check-'+String(j)).is(':checked')) {
sum += price[i][j];
$('.cxema-'+String(j)).show();
} else {
$('.cxema-'+String(j)).hide();
}
}
sum = String(sum).replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
console.log('Общая сумма: '+sum);
var result = sum + ' руб.';
$('#result .montage').html(result);
return sum;
}