Problem in generating the plots in dynamic inputs

Asked

Viewed 31 times

0

I’m trying to recreate the code below based on one that I analyzed, but it’s not working. I think there is an error in the structure! I need a help.

<script>
    function start()
{
    var select_prog = document.getElementById("select_prog"),
    var select_plano = document.getElementById("select_plano"),
    var select_dura = document.getElementById("select_dura"),
        var input_total = document.getElementById("input_total"),
    input_datavenda = document.getElementById("input_datavenda"),
    input_datafinal = document.getElementById("input_datafinal"),
    input_dt_pagto = document.getElementById("input_dt_pagto"),
    input_parcelas = document.getElementById("input_parcelas"),
    input_venc = document.getElementById("input_venc"),
        input_idplano = document.getElementById("select_plano"),
        var select_tp = document.getElementById("select_tp"),
        var select_op = document.getElementById("select_op"),
    select_tp = document.getElementById("select_tp"),
    select_op = document.getElementById("select_op"),
    boletos_set = document.getElementById("boletos_set"),
    din_set = document.getElementById("din_set"),
    chq_set = document.getElementById("chq_set"),
    cde_set = document.getElementById("cde_set"),
    ccd_set = document.getElementById("ccd_set"),
    id_index = 0;
    select_prog.focus();
    select_prog.placeholder = "Selecione";  
    select_prog.onblur = function()
    {
    select_plano.focus();
    select_plano.placeholder = "Selecione"; 
    select_plano.onblur = function()
    {
    select_dura.focus();
    select_dura.placeholder = "Selecione";  
    select_dura.onblur = function()
    {
        input_datavenda.focus();
        input_datavenda.placeholder = "Selecione data"
    }
    input_datavenda.onblur = function()
    {
        input_datafinal.focus();
        input_datafinal.placeholder = "Selecione data"
    }
    input_datafinal.onblur = function()
    {
    input_total.focus();
    input_total.placeholder = "Digite o total";
    input_total.onblur = function()
        {
        select_tp.focus();
        select_tp.onblur = function()
        {
        input_parcelas.focus();
        input_parcelas.onblur = function()
            {
            input_venc.focus();
            input_venc.onblur = function()
            {
            select_op.focus();
            select_op.onchange = function()
                {
                /*Calculo Parcela*/
                var idplano = parseInt(input_idplano.value);
                var tppagto = document.getElementById("select_tp").value;
                var fmpagto = document.getElementById("select_op").value;
                var dt_pagto = document.getElementById("dt_pagto").value;
                input_total = parseFloat(input_total.value);
                input_parcelas = document.getElementById("input_parcelas").value;
                var divisao = parseFloat((input_total / input_parcelas).toFixed(2));
            for(i=0;i<input_parcelas;i++)
            {
            /*Calculo Datas*/
            var s_datavenda = new Date(input_datavenda.value);
            s_datavenda.setUTCDate(s_datavenda.getUTCDate() + (parseInt(input_venc.value)));    
            s_datavenda.setUTCMonth(s_datavenda.getUTCMonth() + id_index);
            var dia = s_datavenda.getUTCDate();
            var mes = s_datavenda.getUTCMonth() + 1;
            var ano = s_datavenda.getUTCFullYear();
            /*Input dinamico com label*/
            var din_input_id_plan = document.createElement("input");
            var din_input_tp_pgto = document.createElement("input");
            var din_input_fm_pgto = document.createElement("input");
            var din_input_dt_venc = document.createElement("input");
            var din_input_parc_num = document.createElement("input");
            var din_input_parc_val = document.createElement("input");
                var din_input_dt_pgto = document.createElement("input");
                var din_input_pago_val = document.createElement("input");
                var din_label_id_plan = document.createElement("Label");
            var din_label_tp_pgto = document.createElement("Label");
            var din_label_fm_pgto = document.createElement("Label");
            var din_label_d_venc = document.createElement("Label");
            var din_label_dt_venc = document.createElement("Label");
            var din_label_parc_num = document.createElement("Label");
            var din_label_parc_val = document.createElement("Label");
                var din_label_dt_pgto = document.createElement("Label");
            var din_label_pago_val = document.createElement("Label");
            id_index++;
                        din_input_id_plan.type = "number";
                        din_input_id_plan.id = "din_input_id_plan" + id_index;
                        din_input_id_plan.value = idplano;  
                        din_input_tp_pgto.type = "text";
                        din_input_tp_pgto.id = "din_input_tp_pgto" + id_index;
                        din_input_tp_pgto.value = tp_pagto;    
                        din_input_parc_num.type = "number";
                        din_input_parc_num.id = "din_input_parc_num" + id_index;
                        din_input_parc_num.value = id_index;
                        din_input_fm_pgto.type = "text";
                        din_input_fm_pgto.id = "din_input_fm_pgto" + id_index;
                        din_input_fm_pgto.value = fm_pagto;           
                        din_input_dt_venc.type = "text";
                        din_input_dt_venc.id = "din_input_dt_venc" + id_index;
                        din_input_dt_venc.value = dia + "/" + mes +"/" + ano;
                        din_input_parc_val.type = "number";
                        din_input_parc_val.id = "din_input_parc_val" + id_index;
                        din_input_parc_val.value = divisao;
                        din_input_dt_pgto.type = "text";
                        din_input_dt_pgto.id = "din_input_dt_pgto" + id_index;
                        din_input_dt_pgto.value = dia + "/" + mes +"/" + ano;
                        din_input_pago_val.type = "number";
                        din_input_pago_val.id = "din_input_pago_val" + id_index;
                        din_input_pago_val.value = divisao;
                        din_label_id_plan.htmlFor = "id_plan"+id_index;
                        din_label_id_plan.appendChild(document.createTextNode("Id Pl"));
                        din_label_tp_pgto.htmlFor = "tp_pgto"+id_index;
                        din_label_tp_pgto.appendChild(document.createTextNode("Tipo Pgto"));
                        din_label_parc_num.htmlFor = "d_venc"+id_index;
                        din_label_parc_num.appendChild(document.createTextNode("Nº parcela"));
                        din_label_fm_pgto.htmlFor = "fm_pgto"+id_index;
                        din_label_fm_pgto.appendChild(document.createTextNode("Forma Pgto"));
                        din_label_dt_venc.htmlFor = "id_venc"+id_index;
                        din_label_dt_venc.appendChild(document.createTextNode("Dt Venc"));
                        din_label_parc_val.htmlFor = "d_venc"+id_index;
                        din_label_parc_val.appendChild(document.createTextNode("Valor parcela"));
                        din_label_dt_pgto.htmlFor = "dt_pgto"+id_index;
                        din_label_dt_pgto.appendChild(document.createTextNode("Dt Pagto"));
                        din_label_pago_val.htmlFor = "d_venc"+id_index;
                        din_label_pago_val.appendChild(document.createTextNode("Valor Pago"));
                        din_set.appendChild(din_label_id_plan);
                        din_set.appendChild(din_input_id_plan);
                        din_set.appendChild(din_label_tp_pgto);
                        din_set.appendChild(din_input_tp_pgto);
                        din_set.appendChild(din_label_parc_num);
                        din_set.appendChild(din_input_parc_num);
                        din_set.appendChild(din_label_fm_pgto);
                        din_set.appendChild(din_input_fm_pgto);
                        din_set.appendChild(din_label_dt_venc);
                        din_set.appendChild(din_input_dt_venc);
                        din_set.appendChild(din_label_parc_val);
                        din_set.appendChild(din_input_parc_val);
                        din_set.appendChild(din_label_dt_pgto);
                        din_set.appendChild(din_input_dt_pgto);
                        din_set.appendChild(din_label_pago_val);
                        din_set.appendChild(din_input_pago_val);
                        din_set.appendChild(document.createElement("br"));  
                        }
                     }  
                  }
               }
            }
         }
      }
    }
  }
}
</script>
  • The code is quite extensive. Don’t let readers guess what the mistake is, like a puzzle. Start by analyzing the inspect window of the browser you use, which will tell you which error and on which line. After realizing which error and on which line, if you do not know how to resolve, you can redo your issue against that error, including only the minimum code required for the problem

  • Okay. It’s my first post, a question that’s been around for days is unanswered!

  • And it will probably remain unanswered if it doesn’t improve the question. Your question does not have the html associated so that it can be tested, it also does not explain what you are trying to do. All these reasons make an answer difficult if not impossible. Try to create a minimum checkable example of the problem. Also review the guide to how to ask

  • I understand the requirements. I’ll see that you do.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.