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

Combine two entries but have the text stacked

Community Beginner ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Hello there

I am working on a form and I currently have the following code:

Right now, when I click the "Both" circle, it shows the name on one line. Is there any way to have it to where if they choose Debtor 1 or Debtor 2 - it displays as normal; however, when selecting both, it will stack?

1) Select Debtor 1 - Sally Jane

2) Select Debtor 2 - Bobby Jane

3) Select Both - Sally Jane

                          Bobby Jane

At the same time, I feel sure I will need to ensure my text box is bigger but then I'd have to have the alignment set to bottom and that way when stacked, the text will show up properly. Any help would be greatly appreciated.

TOPICS
Acrobat SDK and JavaScript

Views

105

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 29, 2018 Nov 29, 2018

Ok. Disregard. I figured it out.

var v = this.getField("Debtor").value;

if (v=="Debtor 1") {

    event.value = "\n"+getField("Debtor 1").value;

}

else if (v=="Debtor 2") {

    event.value = "\n"+this.getField("Debtor 2").value;

}

else if (v=="Both") {

    event.value = this.getField("Debtor 1").value+"\n"+getField("Debtor 2").value;

}

Likes

Translate

Translate
Community Expert ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

First of all, you need to define the text field as "Multiline" (under Properties - Options).

Then just replace the space character you're adding between the two names with this: "\n"

That's the escape character for a line-break.

PS. In the future, please post your code as text (formatted as code, if possible), not as an image.

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 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

I apologize! So the "\n" worked. However, with it being a form - I know I have to make the box bigger to support the stacking effect. However, if the user choose just Debtor 1 or Debtor 2 - is there a way to tweak the code to still have it drop on the bottom line so that it appears to fall on the line in the form?

Now if I have the 3rd button for Both, it shows up fine.

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 Expert ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Only if you change the multiline property in your code, as the vertical alignment can't be set on its own.

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 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Is there a quick and easy way to get that code or to do this? You're helping me a great deal!

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 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Ok. Disregard. I figured it out.

var v = this.getField("Debtor").value;

if (v=="Debtor 1") {

    event.value = "\n"+getField("Debtor 1").value;

}

else if (v=="Debtor 2") {

    event.value = "\n"+this.getField("Debtor 2").value;

}

else if (v=="Both") {

    event.value = this.getField("Debtor 1").value+"\n"+getField("Debtor 2").value;

}

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 Expert ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

LATEST

Nice solution! My idea was to do it like this:

var v = this.getField("Debtor").value;

if (v=="Debtor 1") {

    event.target.multiline = false;

    event.value = getField("Debtor 1").value;

}

else if (v=="Debtor 2") {

    event.target.multiline = false;

    event.value = this.getField("Debtor 2").value;

}

else if (v=="Both") {

    event.target.multiline = true;

    event.value = this.getField("Debtor 1").value+"\n"+getField("Debtor 2").value;

}

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