Skip to main content
Known Participant
March 2, 2019
Answered

Highlight a field if a box is checked

  • March 2, 2019
  • 2 replies
  • 1176 views

I have a form that is displaying two options, and I need to make it more obvious which one they are selecting. So if they select option A (box) I need text field A to have a border color. If they select checkbox B, I need text field B to have the border color. I've tried running mouseup actions on the boxes but I must be doing something wrong. I am still learning JS..

Thanks!

This topic has been closed for replies.
Correct answer Thom Parker

This MouseUp code will work for a single check box highlighting a field named TextA

if(event.target.value != "Off")

   this.getField("TextA").lineWidth = 1;

else

   this.getField("TextA").lineWidth = 0;

For this to work the border color must already be set.  Change the field name to use on another checkbox

2 replies

Inspiring
March 2, 2019

What code and where did you place the code in the box?

Are you using check boxes?

If so, then you need to code both check boxes.

Are you using a drop down or list box?

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 2, 2019

This MouseUp code will work for a single check box highlighting a field named TextA

if(event.target.value != "Off")

   this.getField("TextA").lineWidth = 1;

else

   this.getField("TextA").lineWidth = 0;

For this to work the border color must already be set.  Change the field name to use on another checkbox

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
March 2, 2019

You're the best. Thank you for all your help!