Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

automatically display instance count in caption of text field

Avatar

Level 4

What is the code I use to make the caption of a text field show the instance count of its parent subform?

5 Replies

Avatar

Level 10

this.parent.index will show you the instance of the subform that you are in.

Paul

Avatar

Level 4

So, how do I make it display?

This was my attempt:

xfa.resolveNode("this.caption.value.#text").value = this.parent.index;

Avatar

Level 10

There is nothing wrong with your code....but you are assigning a numeric value to a string value and javascript does not seem to like that. If you modify the right side of the equation to be:

"" + this.parent.index

Then it seems to work.

Paul

Avatar

Level 4

Woo hoo! Almost there. I need to add 1 to the index because otherwise it starts at 0.

How do I do that?

Avatar

Level 4


OK, I got it to work. This is what I did:

var number = this.parent.index + 1

xfa.resolveNode("this.caption.value.#text").value = "" + number;