Copy link to clipboard
Copied
Hello,
I am relatively new to Javascript in general and I am having trouble finding a solution to my current issue. I have two pieces of code which I have found on this forum previously that I need to be set to the formatting script of a field that is created in my code. these are as follows:
Code 1:
f.setAction("Format", "event.value = util.printf(\"£%,0.2f\",event.value);");
Code 2:
event.richText = true;
var spans = new Array();
spans[0] = new Object();
spans[0].text = event.value;
spans[0].strikethrough = true;
event.richValue = spans;
I need to find a way to combine them together so that they both function. The idea is that I can assign a value to a field that is 500 for example, and it will display as £500.00 with a strikethrough.
Any help is very appreciated.
Copy link to clipboard
Copied
Where is the setAction Format code triggered? Why not just manually format the field that way in the format tab? To set the richText property to true with a script in the field, use event.target.richText=true NOT event.richText=true.
Copy link to clipboard
Copied
The reason that I cant manually format the field in the format tab is because the field itself is created earlier within the code. So the field doesn't exist for me to format until the user selects the relevant options etc. which will create the field. Thanks for the info on event.target.richText, I will update my current code.