Skip to main content
lilleem89
Participating Frequently
December 10, 2018
Answered

How to populate text box from another text box

  • December 10, 2018
  • 1 reply
  • 583 views

OK so I hope I can explain this well enough because it won't let me insert a photo in there. I have a group of text boxes that are roughly like this:

Header 1Header 2Header 3Header 4
PROMISPROMIS1PROMIS2
DASSDASS1DASS2DASS3
HDIHDI1
UEFSUEFS1
LEFSLEFS1

Each one of those text boxes is where a number score is typed in for the PROMIS, DASS, HDI, UEFS and LEFS tests.  As of right now I have those texts box scores populating down to a another text box called "OATS" but when they populate down to the "OATS" text box it is just the numbers and you don't know which test the numbers correspond to. So what I need, if it's possible, is this:

if "PROMIS1" text box, if it has a score of "4" typed in it to populate down to the "OATS" text box as this "PROMIS Phys - 4"

if "PROMIS2" text box has score of "4" then it populates down to "OATS" text box as  "PROMIS Mental - 4"

If "DASS1" text box has score of "4" then it populates down to "OATS" text box as "DASS Dep - 4"

If "DASS2" text box has score of "4" then is populates down to "OATS" text box as "DASS Anx - 4"

If "DASS3" text box has score of "4" then is populates down to "OATS" text box as "DASS Str - 4"

If "HDI1" text box has score of "4" then is populates down to "OATS" text box as "HDI - 4"

If "UEFS1" text box has score of "4" then is populates down to "OATS" text box as "UEFS - 4"

If "LEFS1" text box has score of "4" then is populates down to "OATS" text box as "LEFS - 4"

All of these also need to be separated by a comma once they are in the "OATS" textbox"

The current Java script in the "OATS" text box to just simply populate the numbers is:

// Get the field values, as strings

var s1 = getField("PROMIS1").valueAsString;

var s2 = getField("PROMIS2").valueAsString;

var s3 = getField("DASS1").valueAsString;

var s4 = getField("DASS2").valueAsString;

var s5 = getField("DASS3").valueAsString;

var s6 = getField("HDI1").valueAsString;

var s7 = getField("UEFS1").valueAsString;

var s8 = getField("LEFS1").valueAsString;

// Combine values, separated by a comma

event.value = s1 + "," + " " + s2 + "," + " " + s3 + "," + " " + s4 + "," + " " + s5 + "," + " " + s6 + "," + " " + s7 + "," + " " + s8;

If anyone can help it would be greatly appreciated!! Thank you in advance!!

This topic has been closed for replies.
Correct answer Thom Parker

Simply add in the extra text you want indicating the source. You're answer is already in your question

for example:

var s1 = "PROMIS Phys - " + getField("PROMIS1").valueAsString;

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
December 10, 2018

Simply add in the extra text you want indicating the source. You're answer is already in your question

for example:

var s1 = "PROMIS Phys - " + getField("PROMIS1").valueAsString;

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often