Skip to main content
mcolvin2005
New Participant
September 30, 2017
Answered

Setting a form field to auto fill based on another field

  • September 30, 2017
  • 2 replies
  • 11224 views

First of all i'm new to the calculations in Acrobat but i'm trying to figure out two things

First is i'm trying to Field A and Field B to equal field C

example Field A = Hello Field B=2014 so Field C would equal Hello2014

2nd I have a topaz signature pad that i capture signatures with and i would love to have a script that will auto save the file base on what is in Field C from above after the signature was captured or even open a save as box

This topic has been closed for replies.
Correct answer try67

1. Use this code as the custom calculation script of Field C:

event.value = this.getField("Field A").valueAsString + this.getField("Field B").valueAsString;

2. That's more complicated. To save the file without user interaction requires installing a script on the local machine.

See: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

The alternative is to present the user with the desired file name, and then open that Save As dialog and hope they use it.

2 replies

New Participant
April 3, 2020

try67 - You are brilliant!! - This custom calculation allows the developer to set alternative text formatting such as beeing bold an in a smaller font (set in the property Dialog box). If you simply duplicate the text field then it takes on the text formating of the parent field. I know that you know this, however, other newbies might not so this is a great solution along with concatenating fields together. Thank you again! 🙂 

try67
try67Correct answer
Community Expert
September 30, 2017

1. Use this code as the custom calculation script of Field C:

event.value = this.getField("Field A").valueAsString + this.getField("Field B").valueAsString;

2. That's more complicated. To save the file without user interaction requires installing a script on the local machine.

See: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

The alternative is to present the user with the desired file name, and then open that Save As dialog and hope they use it.

MFHawk
New Participant
November 2, 2021

Hi, I've been looking throughout the community support for javascript to help me with my issue.  Not sure it aligns to this but hope you can help.

I have a form which I have automatically calculating a total based on a series of check box values.  I would like to use that total to then display text in a text box below based on variables of  greater than or less than.  Looking at other threads I have written this script but nothing is displaying in the text field.  Is there something I am missing?

var v = this.getField("C1TotalScore").valueAsString;
if (v=="") event.value = "";
else {
var score = Number(v);
if (score<15) event.value = "Sample Text 1";
else if (score>=16 && score<=32) event.value = "Sample text 2";
else if (score>=33) event.value = "Sample text 3";
}

try67
Community Expert
November 3, 2021

The code looks fine. Check the JS Console for error messages, though.

If no error messages appear share the file for further help.