Problems to concatenate two text fields (one field is blank)

Avatar

Avatar

venturacelia

Avatar

venturacelia

venturacelia

11-10-2016

Hi everyone,

I'm having problems to concatenate two text fields.

I found one way to concatenate the two text fields (this.rawValue = line1.value +  " " + line2.value;), but it doesn't work if the 2snf field I am trying to combine is blank.

The only way they seems to work is if I setup 2 invisible fields at the top of my form (1 for line1 and another one for line2) and then use the below line of code:

if(xfa.record.line2.value != null){

                this.rawValue = xfa.record.line1.value;

} else {

                this.rawValue = xfa.record.line1.value +  " " + xfa.record.line2.value;;

}

As I am new to LiveCycle and my knowledge of javascript is quite limited, I was wondering if someone could advise if there is a better way to do it.

What am I missing?

thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar

venturacelia

Avatar

venturacelia

venturacelia

13-10-2016

Hi.

Yes, both are text fields.

I tried with rawValue but I'm still getting the same result.

Nothing is populated on the form.

Avatar

Avatar

Magus069

MVP

Avatar

Magus069

MVP

Magus069
MVP

12-10-2016

is Line1 and Line2 are textfields?

if yes, instead of using value, you should use rawValue

Avatar

Avatar

venturacelia

Avatar

venturacelia

venturacelia

12-10-2016

Hi Magus069.

Thanks for your reply.

I tried this but I'm still getting a blank value.

If one of the fields are blank, I still need whatever is on the other

field.

E.g.:

Line 1 is address line 1

Line 2 is address line 2

If address line 2 is blank, I still need the address line 1 field to be

populated on my form.

Any suggestions?

Thanks

Avatar

Avatar

Magus069

MVP

Avatar

Magus069

MVP

Magus069
MVP

11-10-2016

Hi there,

If a value is null while trying to concatenate it with another value it will always return an error.

To be able to make it work as if it should be blank instead of null you will have to replace the value by quotations mark to make it work properly.

Hope this help!