Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto-populate a field when it's empty

New Here ,
Jan 20, 2017 Jan 20, 2017

Hi!

I was trying to auto-populate a field with data of another one but only if the field is empty. I can populate the field, the problem is that the 2nd field doesn't update when I made a change in the 1st field.

What I have so far is this:

var a = this.getField("FieldName");

if (event.target.value=="")

{

event.target.value=a.value

}

TOPICS
PDF forms
467
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2017 Jan 20, 2017

Why should it? It already has a value... You need to better define how you want this to work.

Do you want the field to be editable by the user, but if the first field's value is changed that it should overwrite any user-entered value?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 23, 2017 Jan 23, 2017

Yes! That's right. For example, I'm entering my Insurance beneficiary's information in field 1, but then I realized that I misspelled the word or I changed my mind and want to change my beneficiary. So, in the next page I have a funds form that also ask for my beneficiary information. It's not required to be the same as the insurance beneficiary but I realized that most people put the same information. So I want to populate those fields with the same insurance beneficiary information, but they'll have a chance to modified it if they want to put another person as beneficiary for their funds.

Does that make sense? Sorry, I've never studied how to use adobe javascript. This is just a one time work and I need help ><

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2017 Jan 23, 2017
LATEST

You can use a button that will copy the value from the first field to the second when clicked.

The code for that button's MouseUp event will be something like this:

this.getField("Text2").value = this.getField("Text1").valueAsString;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines