Olivier Posted June 13, 2016 Share Posted June 13, 2016 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 ! Quote Link to comment Share on other sites More sharing options...
Olivier Posted June 14, 2016 Author Share Posted June 14, 2016 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, Olivier Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.