These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Set focus when opening form

Morabe
Registered: Nov 21 2006
Posts: 20

I want the focus set to a specific (global) field when a user opens a form.

I've tried using the following code on the docReady event at the root level but I get zero results.

xfa.host.setFocus("xfa.form0966.#pageSet[0].Page1.subHeader.txtServProfileName");

Can someone show me the error of my ways please?

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The SOM path is wrong. First, all the nodes in your form hierarchy should be give nice names, "#pageSet[0]" is not a nice name. Second, the top of the form hierarchy is "xfa.form". Is "form0966" the top of the hierarchy in the hierarchy window? if it is then the SOM path should start "xfa.form.form0966"

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Morabe
Registered: Nov 21 2006
Posts: 20
Thanks for the information Thom but I discovered that setting a docReady focus doesn't work with a global text object. So I had to get creative and change my approach.

First, I added this JS code to my docReady event (top of the hierarchy) -- xfa.host.setFocus("subHeader.txtServProfileName");

This got me the focus I needed but didn't address the global aspect of the text object. A fellow forms developer offered me the following FormCalc script for the object "copy" -- $ = Page1.subHeader.txtServProfileName.rawValue. And it works perfectly!

So now I have the focus set when the user opens the document, and a “simulated” global text object for multiple pages! Life is good again.