Skip to main content
Participating Frequently
April 15, 2021
Answered

User to highlight words by clicking on text

  • April 15, 2021
  • 2 replies
  • 2392 views

I have a fillable form all ready to go except for one thing.  I am looking to make certain words "highlightable" or just a plain underline by the user just clicking on it.  Is this possible? I am very new to this and no nothing about programming.

This topic has been closed for replies.
Correct answer try67

You need a script for it. But in order to write the script you first need to find out the "name" of the comment.

To do that you need to select the comment by clicking it, then open the JS Console (Ctrl+J), and enter the following code into it and press Ctrl+Enter:

 

selectedAnnots[0].name

 

It will print out something like this:

1f7dc8a2-7702-4bca-a7f7-8ee7bb664c53

Copy that string and enter it into the following code, as the Mouse Up event of the button:

 

var a = this.getAnnot(event.target.page, "PASTE COMMENT NAME HERE");

a.hidden = !a.hidden;

 

That's it. After you do that each time you click the button the highlight will appear or disappear.

 

2 replies

Participant
July 27, 2022

Despite your detailed instructions, I, as a layman, did not succeed in integrating the function. Apparently I make a mistake already at the beginning and make a wrong Highlight Comment and/or a wrong button. In any case, the Java Console always returns me an error message, such as "Reference Error Button is not defined". Is there a tutorial video or a more detailed step by step description? Thanks for your help!

Translated with www.DeepL.com/Translator (free version)

bebarth
Community Expert
Community Expert
July 28, 2022

This command line only works for a selected annot, not for buttons...

@+

try67
Community Expert
Community Expert
April 15, 2021

It's possible, but not that simple. It would require creating a highlight comment and a button over the text.

The button can then be used to show/hide the highlight comment each time you click it.

Leah5C70Author
Participating Frequently
April 15, 2021

So, I've created the highlight comment and a button over it.  When I click on it, it does nothing.  How do I make it so it will show and hide the highlight?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 16, 2021

You need a script for it. But in order to write the script you first need to find out the "name" of the comment.

To do that you need to select the comment by clicking it, then open the JS Console (Ctrl+J), and enter the following code into it and press Ctrl+Enter:

 

selectedAnnots[0].name

 

It will print out something like this:

1f7dc8a2-7702-4bca-a7f7-8ee7bb664c53

Copy that string and enter it into the following code, as the Mouse Up event of the button:

 

var a = this.getAnnot(event.target.page, "PASTE COMMENT NAME HERE");

a.hidden = !a.hidden;

 

That's it. After you do that each time you click the button the highlight will appear or disappear.