Expand my Community achievements bar.

SOLVED

SetFocus on a object in a copied subform

Avatar

Former Community Member

Hello!

Inside a subform I have a "Copy" button that copy the entire subfom.

What I want: when user press "Copy", except for coping the subform, I want to set focus on a object (any object) inside newly copied subform.

Is it possible?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Yes you can, you just need to count the current number of instances of the subform (data) and then set the focus to a field in that instance:

_data.addInstance();

var i = _data.count - 1;


xfa.host.setFocus(xfa.resolveNode("data[" + i + "].firstName"));

The underscore before the name of the subform is shorthand for "instanceManager".

Sample here: https://acrobat.com/#d=2pAry7PSy7HdLPidEU2XHQ

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

Yes you can, you just need to count the current number of instances of the subform (data) and then set the focus to a field in that instance:

_data.addInstance();

var i = _data.count - 1;


xfa.host.setFocus(xfa.resolveNode("data[" + i + "].firstName"));

The underscore before the name of the subform is shorthand for "instanceManager".

Sample here: https://acrobat.com/#d=2pAry7PSy7HdLPidEU2XHQ

Hope that helps,

Niall