Здравствуйте. У меня возникает ошибка и не работает подсчет объема при обновлении выпадающих списков.
Javascript:
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
document.querySelector('#result-value').innerHTML = volume;
return volume;
}
$('.calculate-value-input').bind('change', calculateValue())
HTML:
<body>
<form action="" id="calculator-form">
<select name="length" id="length" class="calculate-value-input">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<select name="width" id="width" class="calculate-value-input">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<select name="height" id="height" class="calculate-value-input">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</form>
<p >
Объем: <span id="result-value"></span>
</p>
<script type="text/javascript" src="calculator.js"></script>
</body>