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

combines two text fields

Guest
Feb 02, 2016 Feb 02, 2016

Hello , I created a form with Adobe pro XI . I want to create a text field that combines two text fields ( field1 and field2 ) . How can I do?

TOPICS
Acrobat SDK and JavaScript , Windows
801
Translate
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

LEGEND , Feb 02, 2016 Feb 02, 2016

If the third field does not need to be editable, you can use a custom calculation script for it that is something like the following:

// Custom calculation script

(function () {

    // Get the field values, as strings

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

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

    // Set this field's value by concatenating the two strings

    event.value = s1 + s2;

})();

Translate
LEGEND ,
Feb 02, 2016 Feb 02, 2016

You need to be more specific. Do you want to concatenate the field values as strings, and if so, do you want to include a separator between the two values? Or do you want to numerically add the two field values? Or something else? The more details you provide the better.

Translate
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
Guest
Feb 02, 2016 Feb 02, 2016

Yes, I have two string fields ( Text1 and Text2 ) and I would like to create a third field that combines " Text1Text2 " without other characters between them

Translate
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 ,
Feb 02, 2016 Feb 02, 2016

If the third field does not need to be editable, you can use a custom calculation script for it that is something like the following:

// Custom calculation script

(function () {

    // Get the field values, as strings

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

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

    // Set this field's value by concatenating the two strings

    event.value = s1 + s2;

})();

Translate
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
Guest
Feb 02, 2016 Feb 02, 2016
LATEST

TNK

Translate
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