Copy link to clipboard
Copied
I'm creating a calculator but I cannot display a $ before the number unless there is a space. We've tried various Javascripts but it's becoming more work than it is worth. What are some tips and formatting options?
Copy link to clipboard
Copied
Are you talking about displaying it in a text entry?
Copy link to clipboard
Copied
Yes. So I can't write $$$var_somedollarvalue$$.
Copy link to clipboard
Copied
In JavaScript you just need to append the amount you want to display with the dollar sign.
window.var_somedollarvalue = "$"+window.var_amount;
I created a variable called var_amount, which is the number that is calculated.
Your test caption would just be: $$var_somedollarvalue$$
Copy link to clipboard
Copied
Thank you! Because there was additional funky math before it, I had to truncate all the additional digits using this:
window.cpAPIInterface.setVariableValue("var_truncDollar", "$"+var_vacationTotalx.toLocaleString('en-US', {maximumFractionDigits:2}));
Copy link to clipboard
Copied
Just curious, why did you decided to use the .toLocaleString...method for your number adjustment? Hope you are having a great day!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now