2
I have this jQuery and when I click on the button it updates with the result and gives a refresh on the pag,in vdd changes the test/index.html link to test/index.html? ,I wonder if you have how to do without changing out of pay
<script>
$(function ($) {
$('#enviar').click(function () {
var linhas = $('#linhas').val();
var plantas = $('#plantas').val();
var combo = $('#haoum').val();
var resultado = Number(linhas) + Number(plantas);
$("#tam").attr("value", resultado);
if (combo == "ha") {
} else {
}
});
});
</script>
HTML
<li><div class="tldate">Maio</div> </li>
<li>
<div class="tl-circ"></div>
<div class="timeline-panel">
<div class="tl-heading">
<div class="tabbable" id="tabs-669585">
<ul class="nav nav-tabs">
<li class="active">
<a href="#panel-343761" data-toggle="tab">Padrão</a>
</li>
<li>
<a href="#panel-530451" data-toggle="tab">Customizar</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="panel-343761">
<p>
<form class="form-horizontal" role="form" >
<div class="form-group">
<div class="col-sm-7">
<label for="inputEmail3" class="control-label" contenteditable="true">Espaçamento entre linhas(metros):</label>
</div>
<div class="col-sm-10">
<input type="text" class="input-mini" placeholder="1" id="linhas" value="1" disabled>
</div>
</div>
<div class="form-group">
<div class="col-sm-7">
<label for="inputPassword3" class="control-label">Espaçamento entre plantas(metros):</label>
</div>
<div class="col-sm-10">
<input type="text" class="input-mini" id="plantas" placeholder="1" value="1" disabled>
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<label id="tamanho" class="control-label">Tamanho da área a ser plantada:</label>
</div>
<div class="col-sm-10">
<p><input type="text" class="input-mini" id="tam"> <select id="haoum" class="selectpicker">
<option>ha</option>
<option>m²</option>
</select></p>
<div id="divPrincipal">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label>
<button id="enviar" class="btn btn-default" >Estimar</button>
</label>
</div>
</div>
</form>
</p>
</div>
<div class="tab-pane" id="panel-530451">
<p>
<form class="form-horizontal" role="form" style="">
<div class="form-group">
<div class="col-sm-7">
<label for="inputEmail3" class="control-label" contenteditable="true">Espaçamento entre linhas(metros):</label>
</div>
<div class="col-sm-10">
<input type="text" class="input-mini" placeholder="1" id="linhas">
</div>
</div>
<div class="form-group">
<div class="col-sm-7">
<label for="inputPassword3" class="control-label">Espaçamento entre plantas(metros):</label>
</div>
<div class="col-sm-10">
<input type="text" class="input-mini" id="plantas" placeholder="1">
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<label for="inputPassword3" class="control-label">Tamanho da área a ser plantada:</label>
</div>
<div class="col-sm-10">
<p><input type="text" class="input-mini" id="tamanho"> <select class="selectpicker">
<option>ha</option>
<option>m²</option>
</select></p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label>
<button class="btn btn-default">Estimar</button>
</label>
</div>
</div>
</form>
</p>
</div>
</div>
</div>
It worked Sergio, I’ll edit with html,because I don’t understand why he does it,
– Rodolfo Oliveira
@Rodolfooliveira ok, the problem is that it has a
form
on the page andbutton
withouttype
is the same astype="submit"
because this is the default action ofbutton
when inside aform
. If you don’t need theform
(which sends the data to the server) remove it.– Sergio
I understand Sergio, thank you for your help and sorry for the inconvenience
– Rodolfo Oliveira
@Rodolfooliveira I’m glad I helped! If the answer solved the problem you can mark as accepted.
– Sergio