Highlighted

Set default value of PDF form field as the value of another field in the same PDF form

New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Does anyone know how to make the default value in a field be equal to another field.

For example if I had a field called "Name" and I wanted that field contents to be the Default value in a field called "Name2".  The idea is not having to input the value twice but leaving the possibility to change the value in field "Name2" "the default value" to another value if desired.

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Custom calculation script.

 

Right-click on that field and select Properties from the context menu. Then go to the calculate tab.

 

See slide:

 

custom calc.png

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

173

Likes

Translate

Translate

Report

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

Set default value of PDF form field as the value of another field in the same PDF form

New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Does anyone know how to make the default value in a field be equal to another field.

For example if I had a field called "Name" and I wanted that field contents to be the Default value in a field called "Name2".  The idea is not having to input the value twice but leaving the possibility to change the value in field "Name2" "the default value" to another value if desired.

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

Custom calculation script.

 

Right-click on that field and select Properties from the context menu. Then go to the calculate tab.

 

See slide:

 

custom calc.png

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

174

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 03, 2020 0
Adobe Community Professional ,
Aug 03, 2020

Copy link to clipboard

Copied

There's always many ways to achieve this with javascripting.

 

In  my case, this simple line of code worked for me:

 

 

event.target.value = this.getField("Name").value;

 

 

Use the script as custom calculation script in field "Name".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
Most Valuable Participant ,
Aug 03, 2020

Copy link to clipboard

Copied

You should use event.value here, not event.target.value .

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Where do I put that?  I was thinking in the Default Value under options but that doesn't seem to work

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
Adobe Community Professional ,
Aug 03, 2020

Copy link to clipboard

Copied

If I use event.value instead of event.target.value the Name2 field is not editable.

 

Using event.value =  this.getField("Name").value;  just grabs the value from the other field and doesn't allow the user to type in something different in Name2 field.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
Most Valuable Participant ,
Aug 04, 2020

Copy link to clipboard

Copied

I don't see why that should be the case. And at any rate event.value is how you assign a new value in a Calculation script. If you want the user to be able to manually overwrite the value that's possible, but will require adjusting the script to check the source of the event, or moving the code (and adjusting it, of course) to the Validation event of the Name field, for example.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
Adobe Community Professional ,
Aug 04, 2020

Copy link to clipboard

Copied

Is that what you showed me one time with  "if (event.source && event.source.name =="FieldName") ??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 0
try67 LATEST
Most Valuable Participant ,
Aug 04, 2020

Copy link to clipboard

Copied

Exactly, yes.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2020 1
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Where do I put that?  I was thinking in the Default Value under options but that doesn't seem to work

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
Adobe Community Professional ,
Aug 03, 2020

Copy link to clipboard

Copied

Custom calculation script.

 

Right-click on that field and select Properties from the context menu. Then go to the calculate tab.

 

See slide:

 

custom calc.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 1
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Thanks!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

It works!!!  You the MAN!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0
Adobe Community Professional ,
Aug 03, 2020

Copy link to clipboard

Copied

Great! happy to help and kudos to my mentor Try67 who consistently helps me to become better at this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2020 0