client script, variable, focus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2016 02:52 PM
In the Service Portal, how does one get a form element variable, of a catalog item, within a client script so one can set the focus on that input?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2017 09:53 AM
Here is the web-page source. Dumb question (since I'm not a web developer, but I know a bit of HTML, CSS stuff). Is the sys_display.IO:ba96etc the sys_id of the form?
<input id="sys_display.IO:ba96d7d26fed62004c3e841dba3ee4ed" name="sys_display.IO:ba96d7d26fed62004c3e841dba3ee4ed" class="questionsetreference form-control element_reference_input" onfocus="if (!this.ac) new AJAXTableCompleter(this, 'IO:ba96d7d26fed62004c3e841dba3ee4ed', '', '', 'sys_user');" onkeydown="return acReferenceKeyDown(this, event);" onkeyup="return acReferenceKeyUp(this, event)" onkeypress="return acReferenceKeyPress(this, event)" onpaste="return acReferenceKeyPress(this, event)" autocomplete="off" ac_columns="name;email" ac_order_by="name" value="Laurie Marlowe" role="combobox" aria-autocomplete="list" aria-owns="AC.IO:ba96d7d26fed62004c3e841dba3ee4ed" aria-activedescendant="">
Thanks!
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2017 10:16 AM
if the INPUT tag is the thing you want to set the focus on then you'd use:
document.getElementById('sys_display.IO:ba96d7d26fed62004c3e841dba3ee4ed').focus();
and in more general terms, you can use this mechanism on anything on the form/page that has an id=' blah blah blah'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2017 06:57 AM
Hi Tony,
I noticed something a little strange. After the record producer is submitted, and I open the newly created record, the focus is set to the watch list! If I open any other record in the list (that was not created from the record producer), the focus is set to the top of the form, as it should be! What have I done?
I suppose I could create an onLoad client script for all the records, but that doesn't seem like it should have to be done that way.
Any ideas?
Thanks,
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2017 08:55 AM
Hi Laurie ---
Your NOT going to like this but, I think that the ugly sys_id looking part of your document.getElementById('') is perhaps, maybe, might be, possibly *changing* on you each time the form gets loaded and so your specific document.getElementById('') is only valid ONCE.
What you can do is to place a simple UI MACRO onto the Request/Catalog Item (i.e. adding a UI MACRO Variable type) with a known ID, the FOCUS on that...
E.g.
Here's a simple button UI MACRO that I use
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button name="RefreshBtn" id="RefreshBtn" onclick="refreshBOM()">Refresh Parts Lists</button>
</j:jelly>
Note the id=
Then, in my OnLoad() I use:
document.getElementById('RefreshBtn').focus();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2017 09:12 AM
Hi Tony,
I TOTALLY understand what you are saying....sigh....I'm not a coder at your level, and I wish I was! I'm going to experiment.
Thanks,
Laurie