PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 13, 2022

[FIXED] How add elements like Javascript in Jquery - Table Problems

 May 13, 2022     append, html-table, javascript, jquery, methods     No comments   

Issue

everything was going well until I had two problems with jquery, and this is the second.

I have this javascript code, inside a function, that creates "tr" elements and then through a for it adds them to a table already created in html.

for(let i = 1; i <= plazos; i++) {

    pagosIntereses = parseFloat(valor*(tasas/100));
    pagoAmortizacion = pagoMensual - pagosIntereses;
    valor = parseFloat(valor-pagoAmortizacion);
    
    fechaX = hoy.setMonth(hoy.getMonth() + 1);
    //creacion de las filas
    const fila = document.createElement("tr");
    fila.innerHTML = 
    `   <td>${formatoFecha(fechaX)}
        <td class="valorCuota">${pagoMensual.toFixed(2)}</td>
        <td>${pagoAmortizacion.toFixed(2)}</td>
        <td>${pagosIntereses.toFixed(2)}</td>
        <td>${valor.toFixed(2)}</td>`;
    datosTabla.appendChild(fila);
}

Now I try to pass it to Jquery and I can't make it work, I tried to do the following which was what I logically came up with, but I couldn't

    const fila = $("tr").append(
        `<td>${formatoFecha(fechaX)}
        <td class="valorCuota">${pagoMensual.toFixed(2)}</td>
        <td>${pagoAmortizacion.toFixed(2)}</td>
        <td>${pagosIntereses.toFixed(2)}</td>
        <td>${valor.toFixed(2)}</td>`);
    datosTabla.appendChild(fila);

Solution

I appreciate all of your responses! They have helped me to reach this solution.

$("#tablaBody").append(`<tr><td>${formatoFecha(fechaX)}
        <td class="valorCuota">${pagoMensual.toFixed(2)}</td>
        <td>${pagoAmortizacion.toFixed(2)}</td>
        <td>${pagosIntereses.toFixed(2)}</td>
        <td>${valor.toFixed(2)}</td>`);

I thank you very much



Answered By - user16754567
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing