
let valueInput = document.querySelectorAll('.calculate-value-input')
let totalCostInput = document.querySelectorAll('.calculate-cost-input')



function calculateValue() {

let length = document.getElementById('length')
let width = document.getElementById('width')
let height = document.getElementById('height')

let volume = length.value * width.value * height.value

// if(length.value && width.value && height.value) {
if(volume > 0) {

document.querySelector('#result-value').innerHTML = `Объем: <br><div class="result-right">${volume} <span class="measuring">см <sup>3</sup></span></div>`;

} else {
  document.querySelector('#result-value').innerHTML = '<div style="color:red">Выбраны не все параметры</div><br><br>';

}



return volume;
}


function calculateCost() {

let quantity = document.getElementById('quantity').value
let price = document.getElementById('quantity').options[document.getElementById('quantity').selectedIndex].getAttribute('data-price')
let totalCost = quantity * price
let totalCostNum = totalCost.toLocaleString()



// if(quantity.value && price.value) {
if(totalCost > 0) {

document.querySelector('#result-cost').innerHTML = `Стоимость: <br><div class="result-right">${totalCostNum} ₽</div><br> Цена за единицу: ${price} ₽<br><br>`;


} else {
  document.querySelector('#result-cost').innerHTML = '<div style="color:red">Выбраны не все параметры</div><br><br><br>';


}

}


$('.calculate-value-input').bind('change', calculateValue)
$('.calculate-cost-input').bind('change', calculateCost)













