2
I need that in the script below, when selecting the dropdown
it makes the calculation automatically without having to click the button calcular
.
Another thing I wanted is when I marked the checkbox
multiplied by 2 the total value.
<head>
<script type="text/javascript">
window.onload = function () {
var i = function (id) {
return document.getElementById(id);
}
i("calcula").onclick = function () {
var c1 = i("campo1").value;
var c2 = i("children-qnt").value;
var c3 = i("iv").value;
i("resultado").innerHTML = parseInt(c1) * parseInt(c2) * parseInt(c3);
}
}
</script>
</head>
<body>
<input type="checkbox" id="iv" value="2"/></br>
<input type="text" id="campo1" value="10"></br>
<select name="children-qnt" id="children-qnt">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<div id="children">
<button id="calcula">calcular</button>
Result: <span id="resultado">0</span>
</div>
</body>
And how to pass this result to a variable or field in php?
– Fabio Henrique
@Fabiohenrique in this case it is more interesting you open a new question, are different doubts.
– Renan Gomes