0
Good afternoon, I have a function in javascript, and it does not enter the IF, the field txtTipodePlano is filled as "MONTHLY", it should enter, only it falls in Else, follows as I am doing:
if (document.getElementById("<%=ckPosPago.ClientID%>").checked) {
var t = document.getElementById('txtTipodePlano').value;
if (t == "MENSAL") {
now = new Date;
var dia_atual = now.getDate();
var atual_data = toDate(document.getElementById("<%= txtDataInicio.ClientID %>").value);
var dia_escolha = document.getElementById("<%= txtDiaVencimento.ClientID %>").value;
function toDate(atual_data) {
let partes = atual_data.split('/');
return new Date(partes[2], partes[1], partes[0]);
}
if (parseInt(dia_escolha) > parseInt(dia_atual)) {
var data_tolerancia;
var total_dias = dia_escolha - dia_atual;
atual_data.setDate(atual_data.getDate() + parseInt(total_dias));
document.getElementById("<%= txtVencimentoC.ClientID %>").value = atual_data.format("dd/MM/yyyy HH:mm:ss");
var tol = (document.getElementById("<%= txtToleranca.ClientID %>").value);
atual_data.setDate(atual_data.getDate() + parseInt(tol));
document.getElementById("<%= txtDataTolerancia.ClientID %>").value = atual_data.format("dd/MM/yyyy HH:mm:ss");
} else {
var data_tolerancia;
var total_dias = dia_escolha - dia_atual;
atual_data.setDate(atual_data.getDate() + parseInt(total_dias));
document.getElementById("<%= txtVencimentoC.ClientID %>").value = atual_data.format("dd/MM/yyyy HH:mm:ss");
var tol = (document.getElementById("<%= txtToleranca.ClientID %>").value);
atual_data.setDate(atual_data.getDate() + parseInt(tol));
document.getElementById("<%= txtDataTolerancia.ClientID %>").value = atual_data.format("dd/MM/yyyy HH:mm:ss");
}
} else {
function toDate(data) {
let partes = data.split('/');
return new Date(partes[2], partes[1] - 1, partes[0]);
}
var atual_data1 = toDate(document.getElementById("<%= txtDataFim.ClientID %>").value);
document.getElementById("<%= txtVencimentoC.ClientID %>").value = atual_data1.format("dd/MM/yyyy HH:mm:ss");
var tol = (document.getElementById("<%= txtToleranca.ClientID %>").value);
atual_data1.setDate(atual_data1.getDate() + parseInt(tol));
document.getElementById("<%= txtDataTolerancia.ClientID %>").value = atual_data1.format("dd/MM/yyyy HH:mm:ss");
document.getElementById("<%= txtpropor.ClientID %>").value = null;
}
}
This is how the txt is:
<asp:TextBox ID="txtTipodePlano" runat="server" CssClass="form-control"></asp:TextBox>
It enters right in ckPosPago, only it doesn’t enter t == "MONTHLY". I have researched, changed several times, but none it enters the IF, I thank.
Artur, it worked, he enters the if, only now I have a problem passing the value to a textbox, he informs that is null. Could help me?
– Mariana