1
I would like to know how to take a value of a input
, do the calculation and play the result in another input
. Example: imc = peso x (altura)²
.And when one puts the height and weight on inputs
, the calculation will be done and will appear in input
of IMC.
I also have to perform calculations in other fields, but I would like a help because I do not know how to do these calculations, whether and in PHP or Javascript?
Follow the code below:
<div>
<input class="campo-form-c" type="text" name="pesoatual" placeholder="Peso Atual">
</div>
<div>
<input class="campo-form-c" type="text" name="altura" placeholder="Altura">
</div>
<div>
<input class="campo-form-c" type="number" name="idade" placeholder="Idade"></br>
</div>
<div>
<input class="campo-form-c" type="date" name="datan" placeholder="Data de nascimento"></br>
</div>
<div>
<input class="campo-form-c" type="text" name="medidab" placeholder="Medida do Braço" maxlength="5">
</div>
<div>
<input class="campo-form-c" type="text" name="medidat" placeholder="Medida Tricipital" maxlength="5">
</div>
<div>
<input class="campo-form-c" type="text" name="medidaabd" placeholder="Medida Abdominal" maxlength="5"></br>
</div>
<div>
<input class="campo-form-c" type="text" name="imc" placeholder="IMC" maxlength="4">
</div>
<div>
<input class="campo-form-c" type="text" name="gorduratricpital" placeholder="Gordura Tricipital" maxlength="5">
</div>
<div>
<input class="campo-form-c" type="text" name="circunferenciabraço" placeholder="Circunferência do Braço" maxlength="5"></br>
</div>
<div>
<input class="campo-form-c" type="text" name="circunferenciambraço" placeholder="Circunferência Muscular do Braço" maxlength="5"></br>
</div>
You can only do it in javascript yes. Take a look at this link: http://wbruno.com.br/javascript-puro/calculo-simples-entre-inputs-resposta-em-outro/ . And here the code working: http://wbruno.com.br/examples/calc-simples/ Only adapt for your calculations.
– Fernando VR
even on the net if you search "imc calculation in javascript" you will find several ready codes q tbm da pra vc adapt, for example: http://www.emagrecerpravaler.com/wp-content/uploads/2017/02/calc.1-cod-html.txt
– Fernando VR