Expand my Community achievements bar.

Copy and merge content from several TextFields to another TextField

Avatar

Level 3

Hello there,

I have this form in which the user has to enter some codes (letters and numbers) in some textfields, and what I need is those codes to appear on every page of the form (as long as the name, last name, etc which I managed to make them appear all over the form by using global bindings, thanks to this forum ) on another TextField, but they have to appear like this: CODE01, CODE02, CODE03

Ant ideas on how to make this? I guess is something to do with arrays or so, but have very little knowledge on this.

Thanks!

17 Replies

Avatar

Level 5

Hi,

I need more information. When have to appear th CODE01, CODE01?

Avatar

Level 3

hi! as soon as the user finish enetering the codes on the first page, they automatically have to appear on the header on the remaining pages, this anwser your question?

Avatar

Level 5

Hi,

soory but my english is not the best.

I thought yo solved this problems with global binding?

For example:

  • the user-enter-data-field on site 1 have the objectname "CodeEnter"
  • the fields which should have the same value  on site 2, 3.. will get the same objectname "CodeEnter"
  • all this fields get a global binding
  • you have to go to "object" | "binding" | "databinding" | "global"

I thought you need a code as:

switch(CodeEnter.rawValue)

{

//The user enter the following string -> Variant 1 -> then the target field will filled with CODE01

case "Variant 1":

     YourTargetField.rawValue = "CODE01";

     break;

//The user enter the following string -> Variant 2 -> then the target field will filled with CODE02

case "Variant 2":

     YourTargetField.rawValue = "CODE02";

     break;

//You could use the case "": so often you want

}

Could I help you?

Mandy

Avatar

Level 3

Mandy, thanks! but the thing is that i need the value from several inputs (text fields) to be merged in to one text field:

Suppose I have:

  • TextField01 = code01
  • TextField02 = code02
  • TextField03 = code03

I need this values to appear on TextField04 like this code01, code02, code03

Is this more clear?

Avatar

Level 8

In the calculate event of TextField04 you can put the following JavaScript:

this.rawValue=TextField01.rawValue+", "+TextField02.rawValue+", "+TextField03.rawValue;

Kyle

Avatar

Level 5

Kyle was faster then I but I would write the same . He's right.

Kind regards Mandy

Avatar

Level 8

Sorry. Didn't mean to intrude...

Kyle

Avatar

Level 3

Thanks kyle!

It works perfectly, now I have another issue, suppose I regret and I delete one of the codes I entered previously, i.e. the code from TextField01. I´m getting in the TextField04: CODE01, null, CODE03

Any ideas on how to fix this?

Avatar

Level 8

this.rawValue=(TextField01.isNull?"":TextField01.rawValue)+(TextField02.isNull?"":", "+TextField02.rawValue)+(TextField03.isNull?"":", "+TextField03.rawValue);

Kyle

Avatar

Level 5

@Kyle: Everything is ok. It's only important that it gives an helpful answer..

Kind regards from Germany, Mandy

@Kyle: JSP/JSPL-Syntax. I used this one year ago. It's a very good idea to use for this. Method "isNull" I don't used for a long time and forgot it. Great idea to use this method. I will give you a helpful click

But I have one question.I culdn't find in the LCD-help.

  • isNull ask for rawValue == null; and rawValue =="";
  • I mean is the textobject isNull, when the user makes an entry and then he delete this entry?
  • What can we do for this "problem":
  • When I make an entry in textField1, 2 and three. Everything works correct. Now I delete textField1 or textField2, then I have ", textField3.rawValue" as entry in the field.

Thx Mandy

Avatar

Level 3

Thanks again!

But now I get onyl values from 2 and 3, not the first one. I´m trying but I can´t figure it out....

values.png

Avatar

Level 8

Here's a slight improvement that's a bit more verbose:

myArray=[];

for (var a=1;a<4;a++){

if (xfa.resolveNode("TextField0"+a).rawValue!=null && xfa.resolveNode("TextField0"+a).rawValue!=""){

  myArray.push(xfa.resolveNode("TextField0"+a).rawValue);

  }

}

this.rawValue=myArray.join(", ");

Kyle

Avatar

Level 3

I can´t geit to work either....

instead of TextField0 I use form1.Subform1.TextField

Avatar

Level 5

@elunicotomas:

This is no problem.

Rename your textobject in

  • TextField01
  • TextField02
  • TextField03

Then it will works.

example.jpg

When you use xfa.resolveNode  form1.Subform1 is not necessarily.

@Kyle:

Cool. Really. Thx.

Avatar

Level 3

Kyle, thanks again for all your help!

I finally used one of the first options you suggested:

this.rawValue = (form1.Subform1.TextField8.isNull?"":form1.Subform1.TextField8.rawValue)

    +(form1.Subform1.TextField9.isNull?"":", "+form1.Subform1.TextField9.rawValue)

    +(form1.Subform1.TextField10.isNull?"":", "+form1.Subform1.TextField10.rawValue)

    +(form1.Subform1.TextField11.isNull?"":", "+form1.Subform1.TextField11.rawValue)

    +(form1.Subform1.TextField12.isNull?"":", "+form1.Subform1.TextField12.rawValue)

    +(form1.Subform1.TextField13.isNull?"":", "+form1.Subform1.TextField13.rawValue)

//and so on, until the last field

It´d be nice to have it done by using the last piece of code you wrote, the one with the array and the loop, but i couldn´t make it work

Thanks!

Avatar

Level 8

Name all of the text fields you wish to merge 'TextField' (not the field performing the calculation) and use this:

myArray=[];

for (var a=0;a<TextField.all.length;a++){

if (xfa.resolveNode("TextField["+a+"]").rawValue!=null && xfa.resolveNode("TextField["+a+"]").rawValue!=""){

  myArray.push(xfa.resolveNode("TextField["+a+"]").rawValue);

  }

}

this.rawValue=myArray.join(", ");

Kyle