Copy text to field based on check box selection

Community Beginner ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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

TOPICS
Create PDFs, JavaScript, PDF forms

Views

115

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jan 15, 2021 Jan 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.

Likes

translate

Translate

Translate
Adobe Community Professional ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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?

 

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

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.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Excellent! Thanks Nesa, that works perfectly! Much appreciated. Mark. 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

This is all looking great now, but (just to be cheeky!), is there any way for each line to start with a bullet point? Don't worry if not, but now I see the text together bullet points may help the way it reads. Thanks again for your help. Mark 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Yes, you can add it like this:

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;

You can change  "• "  to  "•" if you don't want space between bullet point and text or add even more space if you wish.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

Perfect! Thanks Nesa. Mark 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines