Skip to main content
Participant
October 8, 2021
Question

How do I autofill a textbook when a checkbox is checked?

  • October 8, 2021
  • 3 replies
  • 1298 views

I'm using Adobe Pro 2017 and I would like to create a multiple page document. On the first page is a list of 220 words with checkboxes. On the remaining pages are textboxes that would autofill with the corresponding checkbox. Essentially I am creating flashcards for students that are "created" based on the words that have the boxes checked. I am VERY new to using scripts. I can create the checkboxes and the textboxes but I have no clue where to put the scripts (on the checkbox page or the textbox) and if I have to repeat the process for each individual checkbox. All help is appreciated. 

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
October 8, 2021

Let's say you have 100 fields of each type (named "CK1", "CK2", "text1", "text2", etc.), and that you applied the words to copy as the export values of the check-boxes on the first page. You can then use a button with the following code as the MouseUp event to copy the selected words to the text fields on the following pages:

 

var words = [];
for (var i=1; i<=100; i++) {
	var v = this.getField("CK"+i).valueAsString;
	if (v!="Off") words.push(v);
}

for (var i=1; i<=100; i++) {
	var f = this.getField("text"+i);
	f.value = (i<=words.length) ? words[i-1] : "";
}

 

Participant
October 9, 2021

Thank you for replying! I am very, very new to trying to create using a script. I'm not sure I have the expertise yet to follow your directions. 🙂  I can create the textboxes and checkboxes as you mentioned but I am not sure where exactly I am placing the rest. Would your directions be requiring me to enter a script from the checkbox properties (to copy the export values) and another script from the textbox properties (as shown in your example)?

try67
Community Expert
Community Expert
October 10, 2021

No, neither. It should be used from a button field, although you can also use it as the custom calculation script of a (separate) text field, if you want it to work automatically each time a check-box is ticked (or unticked).

Inspiring
October 8, 2021

Is one box one word or multiple words go to same box?

Do they go in order (any word go to first empty box) or word is tied to specific text field?

Participant
October 8, 2021

It would be one box for each word. I would prefer that the words go in the same order as they appear in the checkboxes but it is not necessary if it would be too complicated to do so.

Participant
October 8, 2021

That should say autofill a text box...not textbook. 🙂