Click here to Skip to main content
15,888,195 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is a PDF Form setup in Adobe Acrobat 9.0
This is my script. It works great but if I change first name later my full name field
does not change. Please Help


// Get the field values, as strings
var s1 = getField("First.Name").valueAsString;
var s2 = getField("Last.Name").valueAsString;

// Combine values, separated by a space
event.value = s1 + " " + s2;

What I have tried:

// Get the field values, as strings
var s1 = getField("First.Name").valueAsString;
var s2 = getField("Last.Name").valueAsString;

// Combine values, separated by a space
event.value = s1 + " " + s2;
Posted
Updated 22-Mar-17 4:47am
v2
Comments
Richard MacCutchan 13-Mar-17 12:27pm    
What script, where does the result go ... ? You have tagged this question PDF, but there is nothing connected with PDF in your question.
Afzaal Ahmad Zeeshan 13-Mar-17 13:38pm    
You need to also handle the value change event to run the same code each time there is a change.

1 solution

You didn't provide enough information (PDF version, how the script get trigger, etc...), I'm guessing you misplacing the script somewhere. Also make sure textbox with First.Name and Last.Name exists.

In Edit Form View, right click the Full Name Textbox, select properties, click on the Calculate tab, select Custom calculation script, Click on Edit... and paste in your scripts

JavaScript
var s1 = getField("First.Name").valueAsString;
var s2 = getField("Last.Name").valueAsString;
event.value = s1 + " " + s2;


After that, click OK and Close. GO back to form preview, change the value in First.Name or Last.Name textbox, then click somewhere on the form, the full name field should change based on the combination of First.Name and Last.Name value.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900