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

Merging Text Field Boxes

New Here ,
Feb 21, 2018 Feb 21, 2018

Copy link to clipboard

Copied

I would like to link two separate field boxes into one?

I would like for "Street Address" & "City, State & Zip" To combine and fill out the "Street Address, City, State &Zip "

I was able to code and add a custom validation script to keep "labels" on the field boxes when someone is working on the PDF .

Also, I was able to link a few boxes together so they mirror the same text, and essentially that is what I am trying to do here, if possible.

Screen Shot 2018-02-21 at 5.20.40 PM.png

TOPICS
PDF forms

Views

6.8K

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 Expert , Feb 21, 2018 Feb 21, 2018

Use a Calculation script to add the fields together. Text can be added in exactly the same way you'd add numbers.

event.value = this.getField("Street Address").value + " " + this.getField("City, State & zip").value;

Votes

Translate

Translate
Community Expert ,
Feb 21, 2018 Feb 21, 2018

Copy link to clipboard

Copied

Use a Calculation script to add the fields together. Text can be added in exactly the same way you'd add numbers.

event.value = this.getField("Street Address").value + " " + this.getField("City, State & zip").value;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
New Here ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

Which field would I put that script? Would I put it for all three? Or to the4 third box that I want to calculation?

Votes

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
New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hi, I'm having a similar question.

I'd like to merge three text fields into one with a little twist.
I'd need only the first line of the third Multiline text field.

Reason being: I'm trying to simplify a naming process where our co-workers
need to use three attributes for naming a file.
Kostenstelle-TicketNr-  and Customername.
Unfortunatelly the Name field in customer also contains the address, phone number etc;
Is there a way to extract only the first line from a multiline text field
and merge the first line with the other two fields?

 

Many thanks in advance for any suggestion and help.

 

Best regards

Screenshot 2021-03-30 at 11.31.10.pngScreenshot 2021-03-30 at 11.31.30.png

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Try this:

var str = this.getField("Name").valueAsString;
var sp = str.substring(
str.indexOf("C"),
str.indexOf("Address")
);
event.value = this.getField("Kostenstelle").value +" "+ this.getField("Ticket").value+" "+ sp;

Votes

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
New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Thx for the swift reply,
I don't know exactly what the script will extract from the Multiline text field 
as I don't have any text field called "Address".

I tried the script but it did not solve my requested issue.


The field "Name" contains the name, address, phone nr. and email address details as one multiline field,
but I'd only like to use the first line being the name of the company.

Using a certain amount of characters won't work as we have customer company names 
with just 3 letters up to 30 or more letters.

I cannot change the original pdf file with the forms as it has been simplified (from 7-8 text fields to one multiline in order to allow 1-step copy paste from other software systems).

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hi, script will extract text between letter "C" ("C" is included) which is starting letter and "Address" which is in begining of second line. That means in your case,it will extract first line as you asked for.

Take a  look at photo:

Izrezak.PNG

 

Votes

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
New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

now I see!

In this case it works; but for the example
I put  COMPANY NAME as a a placeholder for our customer company names.
I cannot post our customer names here, sorry.

 

Using silly made up names like
"your company rocks ltd"
"whatever the client wants is rule nr one distribution"

"A B or Cdobe"
"ApplePie and Plumbcake Associates"

"Funny small offices big company global group"

Now You understand I cannot use "C" as the first letter of the company name and stop 
when the script findes "Address".

 

I'd need to start looking at the beginning of the text field

and stop when it sees the first line break?

 

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Try this then:

var str = this.getField("Name").valueAsString;
var sp = str.substring(
str.indexOf('[a-zA-Z0-9]'),
str.indexOf('\r'));
event.value = this.getField("Kostenstelle").value +" "+ this.getField("Ticket").value+" "+ sp;

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Sorry I just realised I posted wrong code, sorry about that, I fixed code above, test it and see if it works.

Votes

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
New Here ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Thx for your efforts!
I’ll try first thing in the morning tomorrow and report back to you

Best regards
Karl

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

The easist way to get a line from a multiline field is to split it.

 

var aNameLines = this.getField("Name").value.split("\n");

 

Now you can get the data of interst by just getting the line number

 

var strName = aNameLines[0];

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Thanks Thom, that is nice to know, but for me it doesn't work with "\n" it returns all lines but it does work with "\r".

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Here's a more general solution:

 

var aNameLines = this.getField("Name").value.split(/[\r\n]+/);

 

 

 

This code also removes blank lines.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

That one works fine, just please edit your post, code is missing "/" so people don't get confused when they try to use code.

Votes

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
New Here ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Hi Thom, Hi Nesa

 

thank you all for the inputs.
I've tried and I get exactly what I wanted.

Anyhow, it does not remove the blank lines in the split command?


The code I used now is inserted below:

var aNameLines = this.getField("Name").value.split(/[\r\n]+/);
var strName = aNameLines[0];
event.value=this.getField("Kostenstelle").value + "-" + this.getField("Ticket").value+ "-" + strName + ".pdf";

 

Votes

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

LATEST

It removes blank lines that do not contain spaces and tabs.  If you want to include all whitespace in the split, then use this code.

 

var aNameLines = this.getField("Name").value.split(/[\r\n]+\s*/);

 

Cheers,

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

fixed

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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