• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

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

1.6K

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert ,
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?

 

 

Votes

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 

Votes

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 Expert ,
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.

Votes

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. 

Votes

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 

Votes

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 Expert ,
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.

Votes

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 

Votes

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
New Here ,
Sep 05, 2021 Sep 05, 2021

Copy link to clipboard

Copied

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

Votes

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 Expert ,
Sep 05, 2021 Sep 05, 2021

Copy link to clipboard

Copied

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).

Votes

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
New Here ,
Sep 06, 2021 Sep 06, 2021

Copy link to clipboard

Copied

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!

Votes

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 Expert ,
Sep 06, 2021 Sep 06, 2021

Copy link to clipboard

Copied

LATEST

See if this is what you want, script is in "Short Term" field as "Custom calculation script", it will be easy for you to add new fields and text into the script:

https://drive.google.com/uc?export=download&id=1ds1d-oje2GfA_DCXBiC5HXoeKo0I4xeF 

Votes

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