Page 1 of 1

convert numbers to a string and currency

Posted: Mon Oct 02, 2017 2:28 am
by jwallner
I am looking for examples of how to display a number as currency in a text field. Everything I have tried does not work. This program has everything but this function.

Like this:

Price $: 1,000

I was able to display the text and the value, but can't figure out how to do the formatting to show the value of "Editbox3"(my test number field) as currency.

"Price: $" + [Editbox3].toString()

Am I missing something that is built-in? Any help would be great.

John

Re: convert numbers to a string and currency

Posted: Mon Oct 02, 2017 3:07 am
by BaconFries
Have you read from the following:
Conditions

Re: convert numbers to a string and currency

Posted: Mon Oct 02, 2017 5:56 am
by Pablo
This program has everything but this function.
This is not specific to this program. You will need to implement this with JavaScript.
Just like Bacon Fries suggested you can try to use conditions..
http://www.wysiwygwebbuilder.com/suppor ... ions4.html

Re: convert numbers to a string and currency

Posted: Mon Oct 02, 2017 11:47 pm
by jwallner
Thanks for the reply. I already have the symbol and the number. The problem with the format is that it shows it as a decimal and not currency.

This is what I have now:

Price: $ 1134.00

What I would like to see is this:

Price: $ 1,334.00

How would conditions change a decimal point to a comma? Pablo, your example does not show a number large enough to example this. I totally understand that the program does not do this, but it seems logical that a form may require this format and that it maybe the program should be able to do it.

Thanks again,

John

Re: convert numbers to a string and currency

Posted: Tue Oct 03, 2017 6:03 am
by Pablo

Re: convert numbers to a string and currency

Posted: Wed Oct 04, 2017 12:46 am
by jwallner
:) I have something that works on a test page. I just need to rename a few things, but this function works and converts any decimal to a price in US dollars. baseprice and Editbox3 are number fields, and Editbox7 and baseprice_str are string values.


<script>
function myFunction() {

var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
});

// Use it.
var amount = document.getElementById("Editbox3").value;
document.getElementById("Editbox7").value = formatter.format(amount);

var amount2 = document.getElementById("baseprice").value;
document.getElementById("baseprice_str").value = formatter.format(amount2);
}
</script>