0
How do I generate plots using jQuery?
I got the field:
Valor
Plots
amount paid
Best day to pay
The code would take the valor
and subtracted by valor pago
with the remaining value would generate the aparcelas
according to the melhor dia para pagamento
.
- Example:
I am payment $ 400,00 in 3x, the expiration will always day 10.
1 - R$133,33 - 10-08-2019
2 - R$133.33 - 10-09-2019
3 - R$133.33 - 10-10-2019
How to proceed?
$('#valorCurso, #valorPago, #parcelas, #melhorDia').focusout(function() {
var valorCurso = $("#valorCurso").val();
var valorPago = $("#valorPago").val();
var parcelas = $("#parcelas").val();
var melhorDia = $("#melhorDia").val();
if (valorCurso != "" && valorPago != "" && parcelas != "") {
$('#tabelaParcelas').show();
valor1 = parseFloat(parseFloat(valorCurso) - parseFloat(valorPago)).toFixed(2);
valorParcela = valor1 / parcelas;
var table = '';
var x = 1;
while (x <= parcelas) {
table += '<tr><td>' + x + '</td>';
table += '<td>data</td>';
table += '<td> R$' + parseFloat(valorParcela) + '</td></tr>';
x++;
}
$('#tabelaParcelas tbody').html(table);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group">
<label class="control-label">Valor</label>
<input id="valorCurso" name="valorCurso" type="text" class="form-control moeda" value="" required/>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div class="form-group">
<label class="control-label">Valor pago</label>
<input id="valorPago" name="valorPago" type="text" class="form-control moeda" value="" required/>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div class="form-group">
<label class="control-label">Parcelas</label>
<input id="parcelas" name="parcelas" type="number" class="form-control" value="" required/>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div class="form-group">
<label class="control-label">Melhor dia</label>
<select id="melhorDia" name="melhorDia" class="form-control">
<option value="05">05</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
</div>
</div>
</div>
<div class="space-4"></div>
<div class="row">
<div class="clearfix form-actions">
<label class="control-label">Parcelas</label>
<table id="tabelaParcelas" style="display:none;">
<thead>
<tr>
<th>Parcela</th>
<th>Valor</th>
<th>Data</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
But the amount of installments is not the client who chooses?
– Vinicius De Jesus
How to generate the amount of plots according to the best day?
– Vinicius De Jesus
@Viniciusdejesus If it is 3 plots the person type in the field
parcelas
and will be generated 3 plots.– Tiago
@Viniciusdejesus Better day, it would be the best day for that invoice to sell, Let’s assume that I am the customer. I always get the 5. My best day can’t be the 5 to pay, so I choose the 10.
– Tiago
@Viniciusdejesus I was able to explain?
– Tiago
@Viniciusdejesus I was able to explain?
– Tiago
@Viniciusdejesus If you can help me, I will be immensely grateful.
– Tiago
I can, but I don’t think I’ll do it today. I’m going to go shopping
– Vinicius De Jesus
@Viniciusdejesus blz, as I evolve here I update this post.
– Tiago
Let’s go continue this discussion in chat.
– Vinicius De Jesus
What’s the problem with the current code ?
– Isac