• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Combine 2 fields into 1

Community Beginner ,
Nov 19, 2018 Nov 19, 2018

Copy link to clipboard

Copied

Making a form which is 11 pages long on page 2 is Surname1 1st field Givenames1 2nd Field on page 11 I have a Name1 i want to combine the first 2 into the 3rd automatically. Really dont know what I am doing do I do script in the first 2 fields or just tell the 3rd field to look and enter info....thanks in advance

TOPICS
Acrobat SDK and JavaScript

Views

239

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
community guidelines

correct answers 1 Correct answer

Community Beginner , Nov 20, 2018 Nov 20, 2018

Hi its ok used this code and it worked perfectly.

event.value = this.getField("Givennames1").value + " " + this.getField("Surname1    ").value;

Thank you for your help

Likes

Translate

Translate
LEGEND ,
Nov 19, 2018 Nov 19, 2018

Copy link to clipboard

Copied

You can use a custom calculation script for the third field, something as simple as the following:

// Custom calculation script for Name1 field

(function () {

    // Get the input field values, as strings

    var s1 = getField("Surname1").valueAsString;

    var s2 = getField("Givenames1").valueAsString;

    // Combine strings, separated by a space, and set this field's value

    event.value = s1 + " " + s2;

})();

It's not clear if this is how you want to combine the two field values, but it should get you started. Post again if you need more help and provide more specific info.

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
community guidelines
Community Beginner ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

Hi this did not work does it matter about tab numbers and does it matter that the original field is on page 2 and the receiving field is on page 11. Where do I put the code in the 3rd tab.

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
community guidelines
Community Beginner ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

LATEST

Hi its ok used this code and it worked perfectly.

event.value = this.getField("Givennames1").value + " " + this.getField("Surname1    ").value;

Thank you for your help

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
community guidelines
Community Beginner ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

comes back with Syntax error21: at line 22

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
community guidelines
LEGEND ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

Can you post the exact code you're using? What I posted is less than 22 lines, so you must be using something different. Also, exactly where did you place it?

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
community guidelines
Community Beginner ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

I copied and pasted the code you showed. dont understand where i put it tried all places you can put javascript. If i upload the form would you be able to take a look. There is no sensitive information on the form.

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
community guidelines
LEGEND ,
Nov 20, 2018 Nov 20, 2018

Copy link to clipboard

Copied

As I mentioned, it is intended to be a custom calculation script for the Name1 field. You'll see where to add it on the Calculate tab of the field properties dialog. You should also remove it from where you've added it elsewhere.

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
community guidelines