0

I have laravel traits that convert numbers to money-currency format. If I want to use it on blade template I only call it like

<td class="text-center"> @money($repayment->admnin) </td>

My problem is, I want to use it inside the tag, how do I suppose to use that @money traits?

here's my code example

$.ajax({
        method: 'get',
        url: `${url}/${due_date}`,
    }).done((data) => {
        let paymentTotal = 10000;
        let { totalInterest, totalPrincipal, paymentTotal,
            due_date, loanNumber, borrowerFullname } = data;
            $('#simulation-table').show();
            $('#totalbayar').append(
                // I want to use that @money here, I tried like this below
                `@money(${paymentTotal})`
            )
    }).fail((err) => {
        console.log(err, 'error coy');
    });

1 Answer 1

1

you can assign an id to <td> like

<td id="xyz" class="text-center"> @money($repayment->admnin) </td>

and in Ajax you can get the value by using jquery or javascript :

$.ajax({
    method: 'get',
    url: `${url}/${due_date}`,
}).done((data) => {
    let paymentTotal = 10000;

    let pay = $('xyz').val() // for jquery
    let pay = document.getElementById("xyz").value // for javascript

    let { totalInterest, totalPrincipal, paymentTotal,
        due_date, loanNumber, borrowerFullname } = data;
        $('#simulation-table').show();
        // and you can use the value like this 
        $('#totalbayar').append(pay))

}).fail((err) => {
    console.log(err, 'error coy');
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.