Jump to content

Formating Price with superscript


Recommended Posts

Hi friends,

I have to create a rule to be able to set a price with superscript on decimal.


I have prepared this :"var price = StringToNumber(Field("PrixBarre"));

return '<z newsize=47.14>' + Math.floor(price) + '<superscript>' +

String(Round(price - Math.floor(price), 2)).replace(/^0/,'').replace(/[\.,]/g,',') + "€";"


It works fine, except when the PrixBarre is 7,50 , then the result I am missing the 0... due to the Round rule. I have no proble with 7,49 as example.


Any idea welcome !

Link to comment
Share on other sites

Hi friends,

just wanted to let you know I have written this, and it looks working fine :


var price = StringToNumber(Field("PrixBarre"));

var pricefull = String(Round(price - Math.floor(price), 2)).replace(/^0/,'')
   if (/(.10|.20|.30|.40|.50|.60|.70|.80|.90)$/i.test(Field("PrixBarre")))
   pricefull += '0';

return  '<z newsize=47.14>' + Math.floor(price) + '<superscript>' + pricefull.replace(/[\.,]/g,',') + "€";



Thanks if you think there is a better way to do it !


Best regards,


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...