143 Posts
Stef
9 years ago
6
Topic

Hi Seblod team,

I have a text field where only numbers will be saved.

I'm trying to format this number like this :

Original  input: 45000 - Formatted: 45,000 XPF

I have try a JS script in STUFF of this text field,i found it on http://stackoverflow.com:

function formatNumber(number)
{
    number = number.toFixed(2) + '';
    x = number.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
} 

This was just to have a comma separate thousand.

But it give no result. 

Thanks for any suggestion...

Get a VIP membership
693 Posts
rpoy
9 years ago
0
Level 1

Hi Stef,

Will you be using this field for future calculations?

thanks,

Randy

143 Posts
Stef
9 years ago
0
Level 1

Hi Randy,

Thank you for your answer...

Yes, i will. That's why field is filled with number like "45000"...

User will suscribe differents people to courses with a "groupx" and then, if there's 4 peoples suscribed, than the result will be 45000*4

But this will be on another form ("subscription")...

4229 Posts
Kadministrator
9 years ago
0
Level 1

If you will be using this numbers further then you must format them at display time, so that original values are stored - so you can ether use javascript or create new typography plugin. Regarding javascript usage - what you are probably missing here is that you need to actuall call this function on each number field using jQuery selectors, just placing it on the page won't do nothing as it is not called anywhere.

9 years ago
1
Level 1

Hi Stef,

Have you found a solution for your need?
Is this topic is always opened for you ?

Regards,
Mehdi.

143 Posts
Stef
9 years ago
0
Level 2

Hi Mehdi,

and thank you for remind me this topic. I didn't have yest the time to have a closer look on this solution as i had to finish all the website. As the solution look not so easy i pushed it on the end of my work, so yes it is still open.

But I will come back here with some question, or maybe use my 1 hour professionnal support to resolve it... Will see :-)

9 years ago
0
Level 1

Hi Stef,

As we seen yesterday during the support session.

If you would like to format a number in the content view of a content type of in the "item view" of a search type, you should:

  1. use a specific typography plugin
  2. use an override of the positionwhich contains the numeric field

Regards,
Mehdi.

Get a VIP membership