I have created a calcuator using Captivate to help calcualte fees for our compnay. The problem is I need to round it to the nearst dollar and I cannot for the life of me figure it out. I know I will need to run a java script but does anyone have an idea on how to do this? Below is my advanced action so I need to round the variable TotaltoDMV. Any instructions you have is greatly appreicated.
TotaltoDMV = (Math.round(TotaltoDMV));
That is indeed the expression in JS. Of course I am NOT a JS expert but whenever I use JS in an advanced or shared action where variables are used which have been calculated in the advanced action, or their value needs to be changed I needed a lot more in the JS window. Maybe that has changed in the most recent version of CP?
One will set the value, one will round to nearest whole number, and one will round to two decimals.
Because they may give a wrong interpretation to what I wrote. Often happens as you prove again.
You are writing out the full action in JS, which is great. The OP has an advanced action which is doing almost the same with the exception of formatting the value of the last variable. You cannot just insert that simple mathematical function in that case, you need to get the value of the Cp variable, convert it and restore the result to the Cp variable. There are three ways to solve this situation,
If we go back to my original response...
Because that never works for me. Reason why I asked if something has changed.
I would encourage you to take 10 minutes and recreate what I did in that little graphic.
I think there is enough information there to do it.
Does it work for you?
Like I said, I consider what I do as simply crafting advanced actions manually - and I love it for many reasons.
It works! Thank you Stagprime!
Glad to hear it!
Thanks for the update.
If you happen to have the CpExtra HTML5 widget, then you have lots of options for rounding numbers and displaying values to a specific number of decimals.