I have a button located at the bottom of a subform.
When clicked the subform repeats.
I want to setFocus on the field located at the top of the new sub-form
so that the user isn't looking at the bottom of the new sub-form after clicking the button.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
The addInstance() method will return the subform just added, so from this you can use the xfa.host.setFocus() method. If you could post an image of your hierarchy I could probably get the code reasonable close, but it will be something like;
var newInstance = _Subform1.addInstance();
xfa.host.setFocus(newInstance.TextField1.somExpression);
You just need to change the _Subform1 and the TextField1 bits.
Hope this helps
Bruce
Views
Replies
Total Likes
Hi,
The addInstance() method will return the subform just added, so from this you can use the xfa.host.setFocus() method. If you could post an image of your hierarchy I could probably get the code reasonable close, but it will be something like;
var newInstance = _Subform1.addInstance();
xfa.host.setFocus(newInstance.TextField1.somExpression);
You just need to change the _Subform1 and the TextField1 bits.
Hope this helps
Bruce
Views
Replies
Total Likes
Bruce,
Your script solved my issue. Thank you. I understand all of what you wrote except the somExpression ending. What does that do?
Thank you,
-Don
Views
Replies
Total Likes
Hi Don,
The TextField1 reference will return a XFAObject that represents the text field on the form. The somExpression is string reference (or address) of the field, will return a string like xfa[0].form[0].form1[0].Subform1[1].TextField1[0] which the setFocus method uses to reference the field.
Regards
Bruce
Views
Replies
Total Likes
Bruce,
Thanks for taking the time to explain that script.
-Don
Views
Replies
Total Likes