Counter decimal number

4 replies·opened May 20, 2019
W
web75May 20, 2019

Hi,
I need to enter the decimal numbers on the counter.
If I put the period or the comma does not work. What should I change?
Thank you!

<div class="col_one_fifth nobottommargin" data-animate="bounceIn">
							<div class="counter counter-large counter-lined"><span data-from="1" data-to="<strong>12.55</strong>" data-refresh-interval="3" data-speed="2000"></span></div>
							<h5>Hours Spent</h5>
						</div>
S
SemiColonWebSTAFFMay 20, 2019

Hello,

This is Definitely Possible but requires some Customization in the js/functions.js File. Find the following code:

value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');

and replace it with:

value = value.replace(/\B(?=(\d{2})+(?!\d))/g, '.');

Then use the following HTML Code:

<div class="counter center"><span data-from="1" data-to="1255" data-comma="true" data-refresh-interval="3" data-speed="2000"></span></div>

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

W
web75May 21, 2019

Perfect thanks, it works.
But I can only do tens of euros with cents. If I also enter the hundreds of euros example 170,20 the counter shows 1,70,22.
Do you have tens and hundreds? Thanks, good job

S
SemiColonWebSTAFFMay 21, 2019

Hello,

Okay we have checked more on this and there is already an inbuilt function to implement this. Please consider reverting back to the old codes and then simply add the data-decimals="2" Attribute to the .counter Element. Example:

<div class="counter center"><span data-from="1" data-to="12.55" data-decimals="2" data-refresh-interval="3" data-speed="2000"></span></div>

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

W
web75May 22, 2019

Fantastik, work!!
Thanks

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard