Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Formatting number to two decimal places

Avatar

Avatar
Validate 1
Level 1
JonMay1
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
JonMay1
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
JonMay1
Level 1

11-05-2021

Hello,

 

I'm working in the HTML for an email creative, trying to force a number field <%= targetData.price %> to two decimal places. It comes through as the lowest number of decimals at the moment ("9" or "12.5". I've used formatDate before, but can't seem to find anything on formatting numbers.

 

Any help would be greatly appreciated.

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

111 likes

Total Posts

309 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

111 likes

Total Posts

309 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile
_Manoj_Kumar
MVP

11-05-2021

Hello @JonMay1 

 

You can use the javascript to limit the decimal numbers

 

1. Create a span element in the HTML where you want to print the price for eg.

Here is the product price: <span id="productPrice"></span>

2. Then in the javascript you can do this.

<script>
var productPrice=<%= targetData.price %>;
var productPriceDecimalLimit=productPrice.toFixed(2); /// Here 2 is the deimal places
document.getElementById('productPrice').innerHTML=productPriceDecimalLimit;
</script>

 

Let me know if that works.

 

 

Answers (0)