We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.
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.
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.
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?
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:
It will print out something like this:
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.
Genius! Thank you so much!
So here is another one for you!
I want a text box to become visible when they click on a checkbox. The check should show up and text should show up on another portion of the form. I have tried the Show/Hide Field, but it doesn't work. What kind of script can I write to accomplish this? I can find out what the text is "named" fine.
You can use something like this as the custom calculation script of the text field:
event.target.display = (this.getField("CheckBox1").valueAsString=="Off") ? display.hidden : display.visible;
Replace "CheckBox1" with the actual name of your check-box field.
Yeah! Thank you again! That worked perfectly!
Okay, so it works perfectly in Adobe Acrobat Pro DC but when I open the form in just Adobe Reader on my tablet it does not work? I think I'm going crazy!
You're not. Unfortunately, almost no scripts will work on mobile devices.
If you're using an iOS device try it in PDF Expert by Readdle. If you're on an Android device try the XODO PDF Reader. Those apps have the best chances of it working.
Well that stinks, didn't work with the other apps either. Can you think of any other way to accomplish this task?
Since you mentioned that it's OK to use an underline you can try the following:
Create just a button over the word and set it as having a transparent fill color, a black border color, and an underline border style. Then add this code as its Mouse Up script:
event.target.lineWidth = (event.target.lineWidth==0) ? 1 : 0;
Hopefully that will work in one of those apps (I haven't tested it in them, though).