Dynamically populating a text field on the Master Page | Community
Skip to main content
July 20, 2011
Question

Dynamically populating a text field on the Master Page

  • July 20, 2011
  • 20 replies
  • 17428 views

I'm trying to populate a text field on the Master Page of a form by having it populate as a user types data into a text field in a content area.  So far, I have it populating when the user puts the cursor into the Master Page text field and then leaves that field after typing data in the text field in the content area.  I want the text field in the Master Page to populate as the user types in the text field in the content area, so it looks like both fields are being filled simultaneously.

The script which now populates the text field in the Master Page is

this.rawValue = MNPD.Form130.Page1.CSIInfo.CPN.rawValue;

This script is in the Enter, Exit, Calculate and Validate events of the Master Page text field.

I suspect that I am not correctly referencing the Master Page text field when trying to put a script in the content area text field events.

From the Hierarchy, the Master Page text field is   MNPD > Master Pages > PageArea1 > CPN and the text field in the content area is

MNPD > Form130 > Page1 > CSIInfo > CPN

I have tried putting the following scripts in the exit event of MNPD>Form130>Page1>CSIInfo>CPN and they have all failed:

MNPD.#pageSet[0].PageArea1.CPN.rawValue = this.rawValue;

MNPD.pageSet[0].PageArea1.CPN.rawValue = this.rawValue;

MNPD.pageSet.PageArea1.CPN.rawValue = this.rawValue;

I even tried renaming Master Pages to MasterPages and replacing pageSet with MasterPages and that didn' t work.

How does one do this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

20 replies

radzmar
Level 10
July 20, 2011

I'm not sure I understood what your're trying to do.

But if you would like to update another fields value while typing you can use this script in the change:Event of the field you're typing in.

July 20, 2011

I'm trying to change the raw value in text field in my Master Page either as the user types in a text field on the form or as the user exits the field in which he typed data.

I know that I have to set the raw value of the text field in my Master Page to the raw value of the text field in which my user is typing. My problem is that I don't know how to refer to the text field in my Master Page by its fully qualified name. I can say 'this' when I'm in the Master Page text field scripts, but I don't know how to refer to that field when I'm in a script of one of the pages.

radzmar
Level 10
July 20, 2011

You can read the full som expression of a field it the script editor.

Go to the master page and select your text field.

Then open the script editor and select any available script.

The first line in the script editor show the som expression such as

form1.#pageSet[0].Page1.TextField2::exit - (JavaScript, client)

To refer to the field use xfa.resolveNode("form1.#pageSet[0].Page1.TextField2").rawValue

July 20, 2011

ARRRRGHHHH!! I knew where som expression was. I just didn't know how to use it. The resolveNode method was what I was missing. I tried it. I now sit here (after typing this) with two fists thrust in the air in VICTORY. !!

July 20, 2011

The answer was very clear and helpful.

Level 3
July 27, 2011

It seems that the master page's objects are not instantiated until after the page is initialized.  I tried referencing the #pageSet[0] in an initialize method and got null but in the form::docReady method it worked.  Is there a reason for this?

July 28, 2011

I don't know the reason. I'm sure there is one. I'm finding LiveCycle and Javascript a bit inscrutable these days, being inexperienced at both. Anyway, putting the necessary code in the docReady event worked. It's maddening how the solution was so simple, and I was so close, but still so wrong. Now if someone would show me how to add an instance to a subform but have it appear in the middle of the array.....

Level 8
July 28, 2011

To have an instance appear somewhere other than the bottom when added, you can use the moveInstance function, i.e. -

_row1.addInstance(true);

_row1.moveInstance((_row1.count-1), newIndexPosition);

where _row1.count-1 is the newly added row and newIndexPosition is where you want the new row to end up.

July 28, 2011

What happens to the instance that was formerly occupying the position marked by newIndexPosition and all the other instances between newIndexPostion and the (new) last instance?

July 28, 2011

I got it to work with one little hitch. The moveInstance method moved the instance to the position after the one designated by newIndexPostion. That's what I wanted so I just let the index of the current instance be the second parameter. I knew it would be simple. Thanks.

Here's the code from the click event:

// Save the current instance index and location

var i = this.parent.index;

var MyLocation = this.somExpression;

// Add the new instance

parent.instanceManager.addInstance(1);

// select the instance to be relocated (in this case, it's the one just added)

var last = this.parent.instanceManager.count - 1;

// Move the new instance to the desired position after the current instance

parent.instanceManager.moveInstance(last, i);

// Set the cursor position for when the screen is redrawn.

xfa.host.setFocus(MyLocation);