Copy link to clipboard
Copied
I'm working on a pdf form with 10 check boxes. I’d like the user to be able to select one or more checkboxes and have the text associated with each checkbox auto populate an editable text field. I entered the script below for the first two checkboxes "VL1" and "VL2" as a test, but the event value for both checkboxes doesn’t display at the same time. Only one shows. If this is working correctly, the user can create a list from the checkboxes and enter text for the TIMELINE, PEOPLE RESPONSIBLE, etc. for each. I am not familiar with JavaScript and am piecing this together from other posts (most useful to me was this one https://answers.acrobatusers.com/What-code-I-auto-populate-text-field-checkbox-activated-q215636.asp...). Perhaps there is an easier way to do this. Any help is greatly appreciated!
var v1 = this.getField("VL1").value;
if(v1 != "Off"){
event.value = "Video record a live session on a phone or computer and post it on YouTube or your organization’s website. \n\n TIMELINE-\n PEOPLE RESPONSIBLE-\n RESOURCES AVAILABLE-\n MEASURES OF SUCCESS-\n --------------------------------\n";
}
var v2 = this.getField("VL2").value;
if(v2 != "Off"){
event.value = "Collect videos or podcasts that you and your program staff would recommend that parents/caregivers view. Put these in one easy-to-find location and share the links with parents/caregivers. \n\n TIMELINE-\n PEOPLE RESPONSIBLE-\n RESOURCES AVAILABLE-\n MEASURES OF SUCCESS-\n --------------------------------\n";
}
Change this line:
event.value = "Collect videos..."
To:
event.value += "Collect videos..."
And add this to the top of your code:
event.value = "";
Copy link to clipboard
Copied
Is this an Acrobat question... if now, which Adobe program?
Copy link to clipboard
Copied
Yes I am creating the form in Acrobat DC.
Copy link to clipboard
Copied
So, did you enter this script as a calculation on the field that is displaying the text?
If so, then the script presents a conflict. There are two different check boxes with two different messages. What happens when both are checked? Are the messages added together? does one have presedence over the other?
Copy link to clipboard
Copied
Yes I entered the script as a calculation on the text field. The problem is when both checkboxes are checked the message for VL2 erases the message for VL1 and I want both messages to show at the same time if the boxes are checked.
Copy link to clipboard
Copied
Change this line:
event.value = "Collect videos..."
To:
event.value += "Collect videos..."
And add this to the top of your code:
event.value = "";
Copy link to clipboard
Copied
That works perfectly! Thanks so much for your help and quick response. Much appreciated!
Copy link to clipboard
Copied
I have a follow on question to this post. The code works to populate the feild when the check boxes are checked. I'd like to be able to edit the text in the feild after it populates. It doesn't seem like this is possible because when I type in the text then click out of the text feild, the new text I typed in disappears. Is there a way to allow the feild to be edited after it has been populated?
Copy link to clipboard
Copied
Hey sharil this is late answer to your question.
Use this line at the beginning of your custom calculation script:
if (event.source && event.source.name =="myField") {
//and add your code here
}
NOTE: Credit to Try67 who coached on me this.
Copy link to clipboard
Copied
It is generally a bad idea to make a field that is both automatically set, and editable. To do this you need to clearly define when the field is in either state. Does the user entry override any future changes to the check boxes, or do changes to the checkbox automatically override the entered value?
One solution is to add another checkbox that explicitly allows for data entry.