Skip to main content
Participant
August 27, 2021
Question

Javascript to make text strikethrough based on other text field

  • August 27, 2021
  • 1 reply
  • 1530 views

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!!

 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
August 27, 2021

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: