Change Focus to Field on Page Load
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2008 08:24 AM
List,
Does anyone know of a way to set focus to a field on load of a page? Currently when we 'create a new' Incident, initial focus is on the Case ID field... We'd like it to set focus to the 'username' field instead.
Any ideas would be greatly appreciated.
Thanks!
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2008 08:39 AM
Probably something could be done with Client Scripts, but I haven't done it. Hopefully someone else can chime in.
I can tell you that default behavior is that the first writable field on the form gets focus, so that's one workaround (to move that field to be the first writable one on the form).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2008 08:48 AM
Try something like this. It sets the focus to the 'Short Description' field on the Incident form when the form loads. Just plug it into an 'On Load' client script.
function onLoad() {
setTimeout("var refocus = document.getElementById('incident.short_description');refocus.focus();",0);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2008 12:54 PM
Thanks Mark. That works fine for setting focus to regular fields (short description) however when I try to set focus to a reference field (caller_id) it's not working. Any ideas?
THanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2008 01:15 PM
You can use a dom inspector to get the exact element ID. Generally for reference fields, the element ID is prefaced by 'sys_display'. For example, to set the focus to the caller_id field on the incident form you would use the following.
setTimeout("var refocus = document.getElementById('sys_display.incident.caller_id');refocus.focus();",0);