Increase in number
-
If the amount is increased, the amount is increased, but when the pressure is 10, if downwards, the amount is 300, and it should be 100. How do you fix that?
$("#kol").change(function() { nV = $(this).val(); oV = this.name; this.name = nV;
p = $(this).parent().parent(); kol = $("#kol").val(); showsum = $("#sum").val(); sum = $("#realsum").val(); if(nV > oV) { mul = parseInt(sum) + parseInt(showsum); } else { mul = parseInt(showsum) - parseInt(sum); } res = p.find("#sum"); res.html(mul); total = 0; $("#sum").val(mul);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js">
</script>
Количевство: <input type="number" id="kol" min="5" value="5" step="5"><br><br>Сумма:
<input type="hidden" id="realsum" value="100">
<input type="text" id="sum" min="100" value="100">
руб
-
$('#num').change(function() { $('#sum').text(this.value * this.name / this.min); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script>
Количество <input id='num' type='number' value='10' min='10' step='10' name='100'>
<br>
Сумма: <span id='sum'>100</span>