$("#calc-type").change(function () {
const typeValue = $(this).val(); //ну или event используйте,как удобно
});
$("#calc-view").change(function () {
const viewValue = $(this).val(); //ну или event используйте,как удобно
});
$("#calc-area").change(function () {
const areaValue = $(this).val(); //ну или event используйте,как удобно
});
$(document).on("change", calcForm, function () {
const typeVal = $("#calc-type").val();
const viewVal = $("#calc-view").val();
const area = $("#calc-area").val();
const step = 100;
console.log(area)
var result = (parseInt(typeVal) + parseInt(viewVal)) + (parseInt(area) * parseInt(step));
$(".calc__total span").text(result)
});
window.addEventListener('click', function (event) {
if(event.target.hasAttribute('data-price')) {
console.log('click button')
const card = event.target.closest('.card-option')
const productInfo = {
id: card.dataset.id,
price: card.dataset.price,
}
console.log(productInfo )
calcPrice()
}
})
function calcPrice() {
// const inputWrapper = document.querySelector('.cart-js');
const inputItems = document.querySelectorAll('.card-option');
let totalPrice = document.querySelector('.price-js');
console.log(totalPrice)
inputItems.forEach(function (item) {
// console.log(item)
const priceEl = item.querySelector('[data-price]');
// const price = document.querySelector('[data-total]');
const currentPrice = parseInt(priceEl.innerText) + parseInt(totalPrice.innerText);
console.log(currentPrice)
})
}