Copy link to clipboard
Copied
Hoping to be able to get a text box to populate automatically in an adobe form I created. I would like when a customer puts their initials in box 1 for the text in box 2 to populate in box 3. For example if a customer was to put their initials in box 1, the price listed in box 2 would then populate into box 3. I have gotten close to the formula but have not found a sting that quite works. Thank you!
Hi,
In Box1 add the following line of code as Custom Calculation Script:
if (!event.willCommit)
console.println(!event.value);
{
this.getField("Box2").value;
}
And in Box3 add this line of code as Custom Calculation Script:
var s = this.getField("Box1").value;
var t = this.getField("Box2").value;
if (s=="") event.value = "";
else event.value = t
Copy link to clipboard
Copied
Post your latest attempt and include where you placed the script, and we can provide some guidance. Will there always be a price in box 2, and if not, what should happen then when initials are in box 1? And what should happen if the user clears box 1?
Copy link to clipboard
Copied
So from what I found I entered the following under properties; calculate; custom calculation script:
event.value = (this.getField("Initial 1").valueAsString=="") ? "" : "Price 1"
I then tried to enter initials in the "Initial 1" box but nothing happens.
Copy link to clipboard
Copied
This script should have worked to put "Price 1" into the field.
There must be something else going on. Look in the Console window to see if any errors are reported.
You'll find a tutorial on the console here:
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
Copy link to clipboard
Copied
I tried it again today and it does in fact bring in literally the words price1 vs the value entered in the price1 text field. Do you know how I can get it to pull the value vs the actual words?
Copy link to clipboard
Copied
Here's the working script:
event.value = (this.getField("Initial 1").valueAsString=="") ? "" : this.getField("Price 1").value;
Notice that "getField()" is used to get the field object, and then the "value" property of the field object.
Copy link to clipboard
Copied
Hi,
In Box1 add the following line of code as Custom Calculation Script:
if (!event.willCommit)
console.println(!event.value);
{
this.getField("Box2").value;
}
And in Box3 add this line of code as Custom Calculation Script:
var s = this.getField("Box1").value;
var t = this.getField("Box2").value;
if (s=="") event.value = "";
else event.value = t
Copy link to clipboard
Copied
THANK YOU! I have been watching tutorials and working on this one for days. That worked perfectly!
Copy link to clipboard
Copied
You're welcome, happy to help.
Would you mind marking my answer as correct?
It means a world to me .