6
I would like help to implement the plot calculation and fill/create inputs according to the number of plots.
Code below and in https://jsfiddle.net/wnm3jhr7/:
$(document).ready(function(e) {
$('#condicao-pag').on('change', 'select', function() {
if($(this).val() == 1){
$('#parcelamento').show();
/*Calcular valor das parcelas (2x, 3x e 4x) e preencher inputs*/
$('#parcelas').show();
}
else{
$('#parcelamento').hide();
$('#parcelas').hide();
$("input[name='parcela[]']").val('');
}
})
$('#n-parcelas').on('change', function() {
/*Calcular valor das parcelas (2x, 3x e 4x) e preencher inputs*/
})
});
<table>
<tbody>
<tr>
<td><label>Total R$</label></td>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td><input type="number" min="0" class="total" value="100" /></td>
</tr>
<tr name="condicao-pag" id="condicao-pag">
<td><label>Condição de pagamento:</label></td>
<td>
<select>
<option value=0>À vista</option>
<option value=1>À prazo</option>
<option value=2>Outros</option>
</select>
</td>
</tr>
<tr id="parcelamento" style="display:none">
<td>Parcelar em</td>
<td>
<select id="n-parcelas">
<option></option>
<option value="2" selected>2x</option>
<option value="3">3x</option>
<option value="4">4x</option>
</select>
</td>
</tr>
<tr id="parcelas" style="display:none">
<td>
<input type="text" name="parcela[]" value="">
<input type="date" value="">
</td>
<td>
<input type="text" name="parcela[]" value="">
<input type="date" value="">
</td>
</tr>
</tbody>
</table>
</body>
The result of this calculation is to appear where? And what is the calculation? Give an example sff
– Miguel
https://jsfiddle.net/wnm3jhr7/, in inputs.
– lucasbento
You just need to create a function that takes the total value and divides by the number of installments.
– relaxeaza