This topic is locked

Setting focus to simple_search field

3/20/2023 11:59:19 AM
ASPRunner.NET General questions
david powell author


Is it possible to set focus to the simple_search field on a form?

this code in the onload event does not work:
var ctrl = Runner.getControl(pageid, 'simple_search');

neither does this, also in onload event:

Both the field name and the ID for the field are the same, at the default of simple_search.

If it is not directly possible, is there a workaround?

Many thanks!


admin 3/20/2023

Runner.getControl() function is only supposed to work with Edit controls on Add/Edit pages. I'm not sure what "simple_search" but it doesn't look like Edit control.

The second approach will work though if you use a correct ID of the edit box. How did you find this ID? It will help if you post a screenshot explaining it.

david powell author 3/20/2023

img alt

This is a screenshot of the form. You are right, its on a 'list' form rather than edit/add.

simple_search is the default full text full screen search option that comes on a list page.
The ID I got from the properties of this component.

But I appreciate identifying the actual ID of a component can be less than straigthforward - where else should I look?

The end result is I want to open a list form with the cursor already on the input field of the search box. (It only saves one mouse move a a click, but that process is repeated hundreds of times a day...)

admin 3/21/2023

What you see on your screenshot is ItemID. It is to be used with ASPRunner.NET API like toggleItem().

What you need is and ID of the element as it appears in HTML code. See the screenshot below.

I also recommend checking DevClub as this is one of the topics that we are talking about there.

img alt

david powell author 3/22/2023

will do many thanks