Highlighted

How do i auto populate text field from multiple checkboxes Into 1 text field

Explorer ,
Jun 23, 2020

Copy link to clipboard

Copied

Hi all,

 

I want to copy multiple text fields into 1 text field (basically trying to create a summary page) using check box.  Please note that i have over 100 questions and towards ecah question there are 4 check boxes i. e Yes, No , N/A and N/I.  Primarily i want the text field to auto populate for the incorrect answer.

Eg,

I have text field 1.12.1.1 with text abcd and check box Checkbox1

I have another text fields 1.12.1.2 with text xyz and checkbox2

 

Now i have both these text fields to be copied into "findings" text field if both the check boxes are clicked as NO

At present i am using this code which works very well with one check box.  When i copy this to the other checkbox finding is replaced and it shows only one text at a time

 

var fFrom = this.getField("1.12.1.1");
var fTo = this.getField("findings");
if (event.target.value == "Off") {
fTo.readonly = false;
fTo.value = "";
}
else {
fTo.readonly = true;
fTo.value = fFrom.value;
}

 

Thanks for all your help

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, PDF forms

Views

100

Likes

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

How do i auto populate text field from multiple checkboxes Into 1 text field

Explorer ,
Jun 23, 2020

Copy link to clipboard

Copied

Hi all,

 

I want to copy multiple text fields into 1 text field (basically trying to create a summary page) using check box.  Please note that i have over 100 questions and towards ecah question there are 4 check boxes i. e Yes, No , N/A and N/I.  Primarily i want the text field to auto populate for the incorrect answer.

Eg,

I have text field 1.12.1.1 with text abcd and check box Checkbox1

I have another text fields 1.12.1.2 with text xyz and checkbox2

 

Now i have both these text fields to be copied into "findings" text field if both the check boxes are clicked as NO

At present i am using this code which works very well with one check box.  When i copy this to the other checkbox finding is replaced and it shows only one text at a time

 

var fFrom = this.getField("1.12.1.1");
var fTo = this.getField("findings");
if (event.target.value == "Off") {
fTo.readonly = false;
fTo.value = "";
}
else {
fTo.readonly = true;
fTo.value = fFrom.value;
}

 

Thanks for all your help

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, PDF forms

Views

101

Likes

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
Jun 23, 2020 1
ls_rbls LATEST
Adobe Community Professional ,
Aug 08, 2020

Copy link to clipboard

Copied

Hi,

 

I was noticing in your script that there's a lot going on. This could be simplified in a variety of ways with much more concise and simpler script.

 

Like, for example, instead of having two checkboxes for a Yes or No answer with different fieldnames, make a pair of checkboxes mutually exclusive.

 

To do so, just rename two checkboxes with the same fieldname and then assign a different export value to each one. 

 

You will have two checkboxes named "Checbox1" but one is going to have "Yes" assigned as the default export value and the other one "No".

 

Then on the "findings" text field use a custom calculation script like this:

 

(this is just an example)

 

var findings = this.getField("1.12.1.1").valueAsString+" "+ this.getField("1.12.1.2").valueAsString;

if(this.getField("Checkbox1").value == "No") { 
event.value =  findings
}


else if(this.getField("Checkbox1").value == "Yes") event.value = "";

Likes

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
Reply
Loading...
Aug 08, 2020 0