Skip to main content
Known Participant
Nov 20, 2025 6:56 PM UTC
Question

Autopopulating text fields on different page

Hello -

I am attempting to create a document where the person can select a checkbox for an item (will have multiple items/checkboxes) and then on the Different page, a text field would auto-fill specific words based on the checkbox on page 1.

 

Example: Page 1 is a "to-do" list such as : blood work, xrays, mri, consultation

The person checks a box next to specific items,

then on another page, text field will automatically populate a phrase, one that is specific to each item 

so in my example, If Blood work, Xrays are both checked then page 2 will write out "blood work checked today" and "xrays ordered" etc. 

Also, each text field on page 2 could autopopulate all possible phrases (like in the first test field/row, each autofill phrase could be filled into this area, same thing with the second text field, etc.) But i would also want to make sure after 1 text field has information autofilled, the next box checked will autopopulate witht the next empty text field.

Sorry I know its a lot, may be more simple than I am explaining, hopefully! If making the code across ultiple pages is too advanced, I would appreciate help making the code where all fields are on the same page too.

6 replies

Nesa Nurani
Community Expert
Community Expert
Nov 20, 2025 7:34 PM UTC

Name your text fields 'result1, result2, result3, result4' and your checkboxes 'cb_blood, cb_xray, cb_mri, cb_consult' then place this in each checkbox as Mouse UP action:

var phrases = {
 "cb_blood": "Blood work checked today.",
 "cb_xray": "X-rays ordered.",
 "cb_mri": "MRI scheduled.",
 "cb_consult": "Consultation completed."};

var fieldName = event.target.name;
var phrase = phrases[fieldName];
var resultFields = ["result1", "result2", "result3", "result4"];
var checked = (event.target.value !== "Off");

if (checked) {
 for (var i=0; i<resultFields.length; i++) {
  var f = this.getField(resultFields[i]);
   if (!f.value) {
    f.value = phrase;
     break;}}} 
else {
 for (var i=0; i<resultFields.length; i++) {
  var f = this.getField(resultFields[i]);
   if (f.value === phrase) {
    f.value = "";}}}

var values = [];
for (var j=0; j<resultFields.length; j++) {
 var f = this.getField(resultFields[j]);
  if (f.value) values.push(f.value);
   f.value = "";}
for (var k=0; k<values.length; k++) {
 this.getField(resultFields[k]).value = values[k];}
Translate
Known Participant
Nov 20, 2025 10:10 PM UTC

is there anything in that code i need to alter? Is not triggering an autofill into the text fields? 

Translate
try67
Community Expert
Community Expert
Nov 20, 2025 10:19 PM UTC

You need to be more specific. What exactly happens when you use the code? Are there any error messages in the JS Console?

Translate