Javascript to make text strikethrough based on other text field
Copy link to clipboard
Copied
Hello - I have a very basic JS for populating a text field based on if Y is entered in another text box.
I now need to be able to generate similar text with portions striken through and I am stuck on how to/if it is possible to format the text that way.
What I currently have:
var abn1 = this.getField("VolaraABNSame").value;
if (abn1=="Y") event.value = "SPECIFIC TEXT."
else event.value = " "
I will have an additional field that if == Y I would need the same text to generate but just with certain words strikenthrough.
Hope that makes sense, thanks!!
Copy link to clipboard
Copied
You would need to tick 'Allow Rich Text Formatting' in text field properties->options tab in field where you want strikethrough and use richValue with spans property:
This is just example code:
var abn1 = this.getField("VolaraABNSame").value;
if (abn1=="Y"){
var spans = new Array();
spans[0] = new Object();
spans[0].text = "SPECIFIC ";
spans[1] = new Object();
spans[1].text = "TEXT";
spans[1].strikethrough = true;
event.richValue = spans;}
else event.value = "";
This will be result:

