convert numbers to a string and currency

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
jwallner
 
 
Posts: 3
Joined: Mon Oct 02, 2017 2:11 am

convert numbers to a string and currency

Post 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
User avatar
BaconFries
 
 
Posts: 5325
Joined: Thu Aug 16, 2007 7:32 pm

Re: convert numbers to a string and currency

Post by BaconFries »

Have you read from the following:
Conditions
User avatar
Pablo
 
Posts: 21574
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: convert numbers to a string and currency

Post 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
jwallner
 
 
Posts: 3
Joined: Mon Oct 02, 2017 2:11 am

Re: convert numbers to a string and currency

Post 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
User avatar
Pablo
 
Posts: 21574
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: convert numbers to a string and currency

Post by Pablo »

jwallner
 
 
Posts: 3
Joined: Mon Oct 02, 2017 2:11 am

Re: convert numbers to a string and currency

Post 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>
Post Reply