Last active
December 14, 2017 11:35
-
-
Save eivko/41e98d259a2182056499519a1bd1b68c to your computer and use it in GitHub Desktop.
Калькулятор объёма на jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input type="number" min="0" name="a" placeholder="a" /> | |
<input type="number" min="0" name="b" placeholder="b" /> | |
<input type="number" min="0" name="c" placeholder="c" /> | |
<input type="number" min="0" name="qt" placeholder="Количество коробок" /> | |
<div class="calc-result"></div> | |
<input type="button" name="send" value="Рассчитать" /> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("input[name=send]").click( function () { // Событие нажатия на кнопку "Расчёт" | |
var a = $("input[name=a]").val().replace(',','.') * 1; // Переменная длины | |
var b = $("input[name=b]").val().replace(',','.') * 1; // Переменная ширины | |
var c = $("input[name=c]").val().replace(',','.') * 1; // Переменная высоты | |
var qt = $("input[name=qt]").val().replace(',','.') * 1; // Переменная количества | |
var result; // Переменная результата | |
result = Math.round(a*b*c*qt).toFixed(0); | |
result = 'Рассчитанный объём = <span>' + result + ' м<sup>3</sup></span>'; | |
$(".calc-result").html(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment