Skip to main content
Known Participant
December 6, 2016
Answered

need to activate line with of a textbox with a checkbox.

  • December 6, 2016
  • 1 reply
  • 1013 views

I'm trying to make a pdf that when you check certain boxes a section of the doc will highlight.

I thought the best way to go about it is to use the lineWidth of a text box.  Not sure if that IS the best way it was just a thought...

But I want to border to be hidden first then when a checkbox is checked it will be visible.  if the box is unchecked it goes back to hidden.

I've tried this in the checkbox action:

var checkBox1 = getField("CheckBox1").value;

var bord = getField("bordr1");

bord.lineWidth = 0;

if (checkBox1 = "Yes") {

    bord.lineWidth = 3;

}

else {

    bord.lineWidth = 0;

}

but it doesn't work.  couple questions

is there a way to just write code instead of putting it in actions?

if not how can I hide the text box by default?  and still be able to display it later?

This topic has been closed for replies.
Correct answer try67

Remove line #3 from your code.

Also, you used the wrong operator in line #5. It should be:

if (checkBox1 == "Yes") {

Regarding the execution of the code: It can be done from several places. For testing purposes you can run it from the JS Console.

Press Ctrl+J to open it, then paste the code into it, select ​all of it using the mouse or keyboard and press Ctrl+Enter to run it.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 6, 2016

Remove line #3 from your code.

Also, you used the wrong operator in line #5. It should be:

if (checkBox1 == "Yes") {

Regarding the execution of the code: It can be done from several places. For testing purposes you can run it from the JS Console.

Press Ctrl+J to open it, then paste the code into it, select ​all of it using the mouse or keyboard and press Ctrl+Enter to run it.

-trickAuthor
Known Participant
December 7, 2016

Thank you!  That worked as I wanted it to.