Copy link to clipboard
Copied
...
Hello Captivaters !...
I have a Javascript issue... I'm working on the division with decimal numbers...
So far my script 1 is :
window.cpAPIInterface.setVariableValue("VD_1", Math.floor(Math.random()*800+200)/100);
var V_1 = VD_1.toLocaleString("fr-FR");
window.cpAPIInterface.setVariableValue("V_2", Math.floor(Math.random()*8)+2);
Then I have Expression => VD_R = VD_1 * V_2
And my sript 2 is :
var V_R = VD_R.toLocaleString("fr-FR");
And eveything seems to be ok :
But sometimes this is what happen :
So I need the V_R variable to display 2 decimal digits !...
I have tried :
V_R.toFixed(2)
After the first line of my script 2... But it doesn't seem to resolve this...
So your help is required !...
😉
...
Too late... wanted to send you here:
Copy link to clipboard
Copied
...
I answer myself as I believe I found a solution...
In fact it appears that the method "toFix" is not compatible with the function "toLocaleString" !!!...
So I had to put this :
var V_R = VD_R.toLocaleString("fr-FR", {minimumFractionDigits: 2});
And it seems to be ok !...
...
Copy link to clipboard
Copied
Too late... wanted to send you here:
Copy link to clipboard
Copied
"C'est l'intention qui compte !..."
Merci Lily !...