move cursor to a section

davejr
Giga Contributor

I have successfully used g_tabs2Sections.setActive(X);   to highlight/activate a section in a form from (1) an onChange client script and (2) from a UI action button,

but the customer wants the users cursor to be placed in that section also.   Can we do that ?   Thank you.

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I think you would just have to set the focus to be the first field in the section. Unfortunately, I'm not aware of a great way to automatically get the first field in the section so you'd have to hardcode the field name. Something like this:



g_form.getControl('fieldname').focus();


View solution in original post

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I think you would just have to set the focus to be the first field in the section. Unfortunately, I'm not aware of a great way to automatically get the first field in the section so you'd have to hardcode the field name. Something like this:



g_form.getControl('fieldname').focus();


Thank you !


I thought I had this working last week.


Since then that environment was cloned over from production.


When I recreate it no longer works - in chrome or firefox.



I can activate the section   - but the cursor is not going to the "focus" field.


davejr
Giga Contributor

I found the prolem, which I corrected.   the "focus" is working as desired - my cursor goes straight to the specified field.   Thanks again !