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
  • 17426 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

Level 8
July 28, 2011

Just as an fyi, I think the index # is zero based while the count is not, which might explain why it would move one position down from where you expected?

July 28, 2011

Indexes are zero-based, but the second parameter of the moveInstance method appears to point to the instance BEFORE which the source instance will be moved. Thus, if you have a five-instance subform, and you want to move the last instance to the third position, the parameters you must pass should evaluate to 4 and 2 respectively.

Level 8
July 28, 2011

That's it exactly, is that not what you were expecting? I'm confused lol

July 28, 2011

It is now. I expected that the second parameter of moveInstance indicated the position to where the instance would be moved, not the position before the target. When I used it that way, moveInstance put the instance two places ahead of the current instance. Anyway, I've got it working. Thanks.

Level 2
February 5, 2014

I was trying to created a dymanic form number but we I click the field changes for but flashes back to the default state.


When I place the code on a button that doesnt force a reflow it works.

But as soon as the form reflow the field resets.

Any ideas?

Also I have a dymanic title bar breaking over 2 pages one the first page the title changes but it doesn't change on the 2 page.

Thanks

Level 2
February 5, 2014

So i solved my own problem. Instead of having the coding run on the button, I moved it to field thats changing and used the calulate event and that works.

Level 2
January 20, 2016

Hello,

I came across this post as help. Though, I seem to be having issues with my javascript or placement of my script.

I wonder if you can detail what you did.

My scenario is:

In design view, I place the following script in change::event -> xfa.resolveNode("form1.#pageSet[0].StudyPLan.TextField").rawValue=this.rawValue;

The intent is to have the text that is entered into "this" field to echoed in the "StudyPLan.TextField" on the master page. (Note that the Textfield on the master page is a Floating field. Do I really need that or can it be left as a standar text field?).

Ideally, I will want the value from "this" to be echoed to pages 2 and so on as the document is populated.

Thanks,

Erik

Level 2
January 20, 2016

Found an alternative answer to reach my goal.

From AcrobatUbsers (https://answers.acrobatusers.com/Live-cycle-8-2-Linking-fields-master-page-q7360.aspx)

I used the Binding feature within the Object properties.

Erik

August 23, 2018

Hello!

I have a similar situation and I don't know how to handle it.

There is a field in the master page which I want to appear on bottom of each page.

In the normal page I have a repeating Subform which can flow on multiple pages and it contains multiple fields.

Scope: In the field from the master page I want to display the last value of a field from the current page.

Example:

Page1 has only one item 0010 -> field from master page on the first page = 0010

Page2 has two items 0020 and 0030 -> field from master page on the second page = 0030

Page3 has three items 0040, 0050 and 0060 -> field from master page on the third page = 0060

...and so on

What I've tried without success:

1.Created a global variable in interface and a text field on the master page with binding set as Use Global Data

2. In the event indexChange of the repeating Subform I have the following JavaScript:

     $record.<name of the global text field>.value = Subform.Field.rawValue

Global field assignment works fine, but it contains the last value from the binded table on each page. From the above example: 0060 on each page.

_Bruce_Robertson
Level 10
August 27, 2018

Hi,

I think you will need a script in the layout:ready event of the field on the Master Page, something like;

var result

var page = xfa.layout.page(this)

var rows = form1.Page1.Table1.resolveNodes("Row1[*]");

for (var i = 0; i < rows.length; i++) {

    var row = rows.item(i);

    if (xfa.layout.page(row) > page) {

        break;

    }

    result = row.resolveNode("TextField1").rawValue;

}

this.rawValue = result;

This script will assign the last value of TextField1 on the same page as the current master page occurrence of the field with the script.  So you will need to change form1.Page1.Table1.TextField1 to match your form.

Regards

Bruce