Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript to make text strikethrough based on other text field

New Here ,
Aug 27, 2021 Aug 27, 2021

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

 

TOPICS
How to , JavaScript , PDF forms
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 27, 2021 Aug 27, 2021
LATEST

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:

Izrezak.PNGexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines