Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to jump to a control

Avatar

Level 2

Hello,

I was wondering if anyone can help me with the correct javascript to use in my form that will jump to a particular control. Basically, when someone clicks a button I want a previously hidden text field to become visible (which I have done), and for the page to 'jump' to that control (which is where I need help).

I would have thought it was something like form1.txtfield.focus() but that doesn't seem to work.

I'd be grateful for any help!

Thanks

Matt

1 Accepted Solution

Avatar

Correct answer by
Level 10

The code is

xfa.host.setFocus('<your field name>');

e.g xfa.host.setFocus('form1.page.txtUserName1');

Nith

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

The code is

xfa.host.setFocus('<your field name>');

e.g xfa.host.setFocus('form1.page.txtUserName1');

Nith

Avatar

Level 2

Thanks very much, that has worked. One quick question though - am I right in thinking that this won't work if the target control is of type 'text'? I've been able to get it to work for a 'text field' control, but not 'text'.

Thanks

Matt

Avatar

Level 10

You are correct. The setFocus() method will not work for the static fields like Text, Image, Rectangle etc.

Nith

Avatar

Former Community Member

Text objects have no place to put the cursor so no you cann "jump" to that location. You can however place a field right before the text and use  that as your jump point. You could set the field to have no borders and no caption. Then make it 1 pixel by 1 pixel and lastly change the background colour to match the page colour. Now when you are in the text th efield is virtually invisible, but you can still "jump" to it.

Paul