1
My question is the following: I have this code where it feeds a table with 3 fields (portion value, start date, end date). From my numerous attempts I have not had success I am trying by a while to do the automatic filling of table.
Ex: if I put a value = 200.00 with start date = 17/04/2019 end date = 17/06/2019.
he already fill by while the dates and corresponding values in the table... Someone can help me with this doubt, I think it’s something silly but as I’m still getting worth every help as learning! Thank you.
function GerarTabela() {
var valor = $("#txtParcela").val();
var data1 = $("#datepicker1").val();
var data2 = $("#datepicker2").val();
var linha = document.createElement("tr");
var campo_data = document.createElement("td");
var campo_valor = document.createElement("td");
var tabela = document.querySelector(".myBody");
var rs = "R$ ";
var valor_completo = `${rs} ${valor}`;
var data_parcela = document.createTextNode(data1);
var data_parcela2 = document.createTextNode(data2);
var valor_parcela = document.createTextNode(valor_completo);
if (valor == null || valor == "") {
alert("Inserir valor da Parcela.");
} else if (data1 == null || data1 == "") {
alert("Inserir data primeiro dia.");
} else if (data2 == null || data2 == "") {
alert("Inserir data ultimo dia.");
} else {
while (data_parcela < data_parcela2) {
campo_data.appendChild(data_parcela);
campo_valor.appendChild(valor_parcela);
linha.appendChild(campo_data);
linha.appendChild(campo_valor);
tabela.appendChild(linha);
//condição que faça incrementar os meses até o ultimo mês.
}
}
};
That function
.addMonth(1)
where’s?– Sam
was a function I was testing, but it didn’t work out and I forgot to delete this line.
– Rodrigo Henriques