Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

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

Former Community Member

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

Former Community Member

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;