This script performs the function that when I give a button, a number is incremented and in the other part it is multiplied by the value given in the variable.
What I want is for the final results of each of them to be shown to me in an input text. How can I do it?
<script type="text/javascript">
var capnum = 0;
var precio = capnum * 100;
var capnum2 = 0;
var precio2 = capnum2 * 180;
function add(){
capnum++;
precio = capnum * 100;
document.getElementById('display').innerHTML = capnum;
document.getElementById('mostrar').innerHTML = precio;
}
function add2(){
capnum2++;
precio2 = capnum2 * 180;
document.getElementById('display2').innerHTML = capnum2;
document.getElementById('mostrar2').innerHTML = precio2;
}
</script>
<button class="n" onclick="add()">AGREGAR CATEGORIA 1</button>
<p></p>
<span class="n">Cantidad:</span>
<div class="m" id="display"><script type="text/javascript">document.write(capnum);</script></div>
<span class="n">Total:</span>
<div class="m" id="mostrar"><script type="text/javascript">document.write(precio);</script></div>
<button class="n" onclick="add2()">AGREGAR CATEGORIA 2</button>
<p></p>
<span class="n">Cantidad:</span>
<div class="m" id="display2"><script type="text/javascript">document.write(capnum2);</script></div>
<span class="n">Total:</span>
<div class="m" id="mostrar2"><script type="text/javascript">document.write(precio2);</script></div>