Skip to main content
pilotmitch
Participant
August 3, 2020
解決済み

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

  • August 3, 2020
  • 返信数 1.
  • 10681 ビュー

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.

このトピックへの返信は締め切られました。
解決に役立った回答 ls_rbls

Custom calculation script.

 

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

 

See slide:

 

返信数 1

ls_rbls
Community Expert
Community Expert
August 3, 2020

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".

pilotmitch
pilotmitch作成者
Participant
August 3, 2020

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

try67
Community Expert
Community Expert
August 3, 2022

We have a pre- and post-travel report with two sections for expenses.  I would like a field called "Lodging.0" to copy its data into "Lodging travel report.0", but I want my users to be able to edit "Lodging travel report.0" in case there are changes to expenses during their trip.  As a workaround, we used a button that applies this formula when clicked: 

 

getField("Lodging travel report.0").value = getField("Lodging.0").valueAsString;

 

Which works, but I was hoping I could make it a bit more automatic.  I greatly appreciate your time and assistance.  


As the custom Validation script of "Lodging.0" enter the following:

 

this.getField("Lodging travel report.0").value = event.value;

 

Note this will also clear the second field if you clear the first. If you want to avoid that change the code to:

 

if (event.value) this.getField("Lodging travel report.0").value = event.value;