Jquery Render currency from table data

This is a table which display transactions, enter image description here

    <td><?php echo $row[id]; ?></td>                        
    <td><?php echo $row[Request_Date]; ?></td>
    <td><?php echo $row[Partner]; ?></td>                       
    <td><?php echo $row[Package]; ?></td>
    <td><?php echo $row[Qty]; ?></td>
    <td id="ammount"><?php echo $row[Ammount]; ?></td>                      
$("tr").find("#ammount").each(function() {
        var data = $(this).html();
        $.fn.dataTable.render.number(',', '.', 2, symbol).display(data);

Now I want to add an enhancement: format the amount using Indonesian format, so for example 25000 will be displayed as “Rp 25.000”;

A Google search pointed me to renderers. I added the render part into my code, and well it doesn’t change the formatting. What is wrong here?


Try this,

        let x = document.querySelectorAll("#ammount"); 
        for (let i = 0, len = x.length; i < len; i++) { 
            let num = Number(x[i].innerHTML) 
            x[i].innerHTML = "Rp "+ num; 

Leave a Reply

Your email address will not be published. Required fields are marked *