Skip to main content
Participant
July 19, 2022
Question

Text field (Forms) - highlighting the text after choosing (pressing) of the form

  • July 19, 2022
  • 1 reply
  • 920 views

Dear members,

 

I hope that someone will be able to help me.

 

I have created a fillabile pdf file.

 

The file contain checkboxes and also text fileds.

 

Is there any ready script with which i can highlight one of few offered text fields (or words) when i will press on one of them.

 

For instance in the pdf i have one row with this question:

 

You eat with: a spoon - a fork  - a knife

Is there a way when i will press on one of the words (spoon or fork or knife)  that word to be automaticaly highlighted with some specific color ?

 

Thanks in advance

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 19, 2022

Not really. First of it, it's extremely difficult finding out exactly on which word the user clicked, and also there's no way to highlight a part of a text in a form field. You can, however, change a word's text color, or underline it, for example.

Participant
July 19, 2022

Thank you very much for your fast reply. Could you send me a script for your proposal ?thanks 

Participant
July 20, 2022

This requires setting the field as having Rich Text Formatting, and then applying the value to it using the richValue property as an array of Span objects, like this:

 

var spans = [];
var span1 = new Object();
span1.text = "a spoon - ";
spans.push(span1);
var span2 = new Object();
span2.text = "a fork";
span2.underline = true;
spans.push(span2);
var span3 = new Object();
span3.text = "  - a knife";
spans.push(span3);

this.getField("Text1").richValue = spans;

 

 


many, many thanks