Hello, there was a problem, I found a code on the internet where the data from the preces come from, but I need to make it take the data from select> option, because the product has different volumes because of this different price, how to do it ... Say, is very necessary
js script
var prices = { 1: 450, 5: 430, 50: 410 } var pricesDiv = document.getElementById('prices'), countInput = document.getElementById('count'), summarySpan = document.getElementById('summary'), priceSpan = document.getElementById('price'); // for (i in prices) { // var div = document.createElement('div'); // div.innerHTML = i + ' шт. — ' + prices[i] + '₽' // pricesDiv.appendChild(div); // } function calculate() { var val = parseInt(this.value) || 0 var multiplier; for (i in prices) { if (val < i) { if (multiplier === undefined) { multiplier = prices[i]; } break; } multiplier = prices[i]; } summarySpan.innerHTML = val * multiplier priceSpan.innerHTML = multiplier } countInput.addEventListener('keyup', calculate); countInput.addEventListener('mouseup', calculate); <select name="main-col" class="form-control sel"> <option value="0" selected>Выберите </option> <option value="Цена: 1100р." >1.2</option> <option value="Цена: 1200р." >1.5</option> <option value="Цена: 1400р." >1.7</option> </select> <div id="prices"> </div> <div> <div> Количество товаров: </div> <div> <input id="count" type="number"> </div> </div> <div> Итого: <span id="summary">0</span> </div> <div> Цена за шт.: <span id="price">0</span> </div>