Why is the decimal value not showing?

So i have my jQuery script ready, but i am struggling with 1 problem , if a value is: $ 10 then everything is fine, but when a value is: $24,99 then it only will show 24 instead of 24,99.

How can i fix this? this is my source:

http://jsfiddle.net/0L2n8wdt/34/

<table width="652" border="0" cellpadding="5" cellspacing="0">
    <thead>
        <tr>
            <th align="left">
                <strong>Product</strong>
            </th>
            <th align="left">
                <strong>Product Price</strong>
            </th>
            <th align="left">
                <strong>How much you want?</strong>
            </th>
            <th align="left">
                <strong>Total Price</strong>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td width="210">Fruit:</td>
            <td width="216">$ 10</td>
            <td width="204">
                <input type="text" />
            </td>
            <td width="204"></td>
        </tr>
        <tr>
            <td>Drinks:</td>
            <td>$ 22,95</td>
            <td>
                <input type="text" />
            </td>
            <td></td>
        </tr>
        <tr>
            <td>Cards:</td>
            <td>$ 5</td>
            <td>
                <input  type="text"/>
            </td>
            <td></td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td></td>
            <td></td>
            <td>Total price of all:</td>
            <td id="total"></td>
        </tr>
    </tfoot>
</table>
$("input").on("keyup", function () {
    var $input = $(this);
    var howMany = parseInt($input.val());
    var unitAmount = parseInt($input.parent().prev().text().replace("$", ""));
    var total = howMany ? howMany * unitAmount : 0;
    $input.parent().next().text("€ " + total);

    var total = 0;
    $("tbody tr td:last-child").each(function () {
        total += parseInt($(this).text().replace("€", "") || 0);
    });
    $("#total").html("€ " + total);
});


Source: jquery

Leave a Reply