How do i convert number field output on front end?

I have a number field created with JetEngine. I want a number such as 250,000 to be shown on the front end as 250K, 500K, etc. How do I achieve this?

Below is how it is currently shown on front end.

image

Dynamic Meta: {je_slots_slot-value}

  1. Will this always be in thousands, or the field will be used also for values like 500?
  2. Will the numbers always be “whole” like 5000, 10000 or also 150 234?

You could create a custom function that takes the custom field value and runs round() or such PHP function on it and returns the string in your desired format. Then call that function using the {echo:functionname} dynamic tag.

Thanks for the reply.

  1. Yes, There will be values like 500, 750, 1000, etc
    2 The numbers will always be in the format like described in point 1 above.

Thanks for the response. However, I have almost zero knowledge of PHP. I can read a code to understand its function but can’t write one. Could you please help in that regard?

Ok, so just to make sure. You have both these cases:

  1. Values >= 1000 that you want to display as 1K, 5K, 250K instead of 1000, 5000, 250000
  2. Values < 1K that must stay intact like 250, 500, 750

I see two possible solutions:

  1. If you need to later do something with this number value (calculations etc.) then I would suggest using two fields. One for the “pure” numeric value like 250000 and another for “display” value in the form of text input like “250K”. Then in the builder you would use the “display” field and for the calculations you use the “pure” numeric field.
  2. If you don’t need to do any numeric calculations, just go for simple text field and input “500” or “250K” there. If this will be inputted by client, then add info about how to do this properly.

You could also write a custom PHP function that would format these values, but let’s leave that for now. Let me know if there are some reasons why my two propositions won’t work for you :slight_smile:

I will not be using these fields for anything else like calculations, so I guess I will go with the text field approach where I would have to enter the values like you suggested. Thanks for helping