Skip to main content
Known Participant
January 15, 2021
Answered

Copy text to field based on check box selection

  • January 15, 2021
  • 2 replies
  • 2597 views

Hello. My form (created using Acrobat Pro) contains a number of text fields (named Text1, Text2, etc.), each with a corresponding check box (Check1, Check2, etc.).  The check boxes allow the user to highlight specific text fields to indicate that the information recorded represents a "priority" area. As the form is long and contains quite a few text boxes it would be really useful if, at the end of the form, all the "priority" text fields the user has selected could be copied into a single text field - providing a neat summary of the priority areas - maybe automatically or by pressing a button.  Would this sort of thing be at all possible? Many thanks

This topic has been closed for replies.
Correct answer Nesa Nurani

As custom calculation script of field where you want to show text use this code and don't forget to set field as 'Multi-line' in field properties under options tab:

var total = "";
for(var i=1; i<=92; i++){
if(this.getField("Check"+i).valueAsString != "Off") 
total+=this.getField("Text"+i).valueAsString+"\n";}
event.value = total;

If you wish to use button instead just change event.value with this.getField("field name goes here").value and put code as Mouse Up event of a button.

2 replies

New Participant
September 6, 2021

Hi Nesa,

I have a similar situation but can't get the script below to work.  I have a number of check boxes.  When each one is check I would like a different bit of text to be inserted into a large textbox thereby creating a "to do" list for my patients.

Thanks,

John

Nesa Nurani
Community Expert
September 6, 2021

Where is text that you wish to be entered in multiline text field,is it in other text fields?

What code did you try?

If you referring to the last script with bullet point,

Il mark part of code you need to pay attention to (field names and number of fields):

var total = "";
for(var i=1; i<=92; i++){
if(this.getField("Check"+i).valueAsString != "Off")
total+="• "+this.getField("Text"+i).valueAsString+"\n";}
event.value = total;

92 - number of checkboxes and text fields(where text is to be populated into multiline text field) you change this to the number of your fields and they need to be named in order(example from the script: Check1,Check2,Check3...etc Text1,Text2,Text3...etc).

New Participant
September 6, 2021

Where is text that you wish to be entered in multiline text field,is it in other text fields?  I would like to be able to define the text which populates when each text box is checked.

What code did you try? Should I run this as a JS Action or a Custom Calculation Script?

Attached is a sample of what I am trying to do

Thanks. I appreciate your help!

Nesa Nurani
Community Expert
January 15, 2021

Yes, it's possible.

1) You want to copy text from priority fields into one field? if yes, you want each priority field text on separate line or just separate by space,dash or something else?

2) How many fields or checkboxes you have exactly?

 

 

Mark5EC1Author
Known Participant
January 15, 2021

Thats great! Ideally I'd like each field text on a separate line. There are 92 text boxes in total with 92 corresponding check boxes. 

Many thanks, Mark 

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
January 15, 2021

As custom calculation script of field where you want to show text use this code and don't forget to set field as 'Multi-line' in field properties under options tab:

var total = "";
for(var i=1; i<=92; i++){
if(this.getField("Check"+i).valueAsString != "Off") 
total+=this.getField("Text"+i).valueAsString+"\n";}
event.value = total;

If you wish to use button instead just change event.value with this.getField("field name goes here").value and put code as Mouse Up event of a button.