<form name="9mmammo">
<input type="text" class="calc" value="1" data-operator="*" data-val="5">
<div>Сумма:
<span class="result">5</span>руб.</div>
</form>
<form name="556ammo">
<input type="text" class="calc" data-operator="*" data-val="10" value="1">
<div>Сумма:
<span class="result">10</span>руб.</div>
</form>
<form>
<input type="text" class="calc" data-operator="+" data-val="3" value="1">
<div>Сумма:
<span class="result">10</span>руб.</div>
</form>
<script type="text/javascript">
var inputs = document.querySelectorAll("input.calc");
var len = inputs.length;
while (len--) inputs[len].onkeyup = showResult;
function showResult() {
var val = this.value = this.value.replace(/\D/g, '');
if(!val) return;
var operator = this.getAttribute("data-operator");
var opval = this.getAttribute("data-val");
var par = this.parentNode || this.parentElement;
var rez = par.querySelector("span.result");
rez.innerHTML = Function('return ' + val + operator + opval)();
};
</script>
миникалькулятор