Skip to main content
gcayton78
Known Participant
March 13, 2018
Answered

Working with checkboxes and code

  • March 13, 2018
  • 2 replies
  • 572 views

Please help.  I am new to this and looking for a code to populate a text box with info from another text box by clicking a checkbox, and clearing the text box when the checkbox is unchecked.

Thank you in advance.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Thom Parker

Questions similar to this one have been asked many times.  Here is a search on this forum:

https://forums.adobe.com/search.jspa?q=Checkbox+textbox

In general, you'll need to Place some JavaScript code into the MouseUp Action on the checkbox.

Something like this.

if(event.target.isBoxChecked(0))

{// Checkbox is checked

   this.getField("TargetField").value = this.getField("SourceField").value;

}

else

   this.getField("TargetField").value = "";

You'll need to change the field names to match your form

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 13, 2018

Questions similar to this one have been asked many times.  Here is a search on this forum:

https://forums.adobe.com/search.jspa?q=Checkbox+textbox

In general, you'll need to Place some JavaScript code into the MouseUp Action on the checkbox.

Something like this.

if(event.target.isBoxChecked(0))

{// Checkbox is checked

   this.getField("TargetField").value = this.getField("SourceField").value;

}

else

   this.getField("TargetField").value = "";

You'll need to change the field names to match your form

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
gcayton78
gcayton78Author
Known Participant
March 13, 2018

Thank you so much!  This is exactly what I needed!