-2
I try to print the W variable on the screen, but I think the js code has some error that does not allow it. How to fix?
Javascript
function calcular()
{
var p = document.getElementById('produto_final');
var q = document.getElementById('alimentacao');
var wi = 9080;
var w = ((wi / Math.sqrt(p)) - (wi / Math.sqrt(f)));
document.getElementById('resultado').innerHTML = w;
}
HTML
<div class="container" align="center">
<div class="col-md-5 col-md-offset-4">
<form class="form-horizontal" action="#" method="#">
<legend>Calculo da Potência:</legend>
<div class="row">
<div class="col-md-9">
<div class="form-group">
<label for="inputEmail3" class="col-sm-6 control-label">Informe a variavel P:</label>
<div class="col-sm-6">
<input type="number" class="form-control" id="produto_final" maxlength="15">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-6 control-label">Informe a variavel F:</label>
<div class="col-sm-6">
<input type="number" class="form-control" id="alimentacao" maxlength="15">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8"><br>
<button type="button" class="btn btn-primary" onclick="calcular()">Calcular</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<p id="resultado"></p>
The error, you declare
q
, but usesf
– MarceloBoni