3344
Views
6
Comments
Solved
Set focus to and select text in input field
Question

Hi, I use the input_SetFocus widget to set the cursor in the SearchInput field together with an onfocus extended property to select the text already present in the input field. This works fine.

I wonder ... does OutSystems provide a more simple way (one statement or so) to achieve the same result?


UserImage.jpg
Fábio Vaz
Solution

Charles Betman wrote:

Hi, I use the input_SetFocus widget to set the cursor in the SearchInput field together with an onfocus extended property to select the text already present in the input field. This works fine.

I wonder ... does OutSystems provide a more simple way (one statement or so) to achieve the same result?




Or Create an action with this Javascript:

(Call action RunJavaScript from HTTPRequestHandler Extension)

Input Param is your textbox


"osjs('#" + WidgetId + "').focus();"+ "osjs('#" + WidgetId + "').select();"


2018-07-03 08-33-54
Tiago Gafeira
Champion

Hi Charles, 

Not really, but you can easily create a web block that encapsulates that functionality so that you don't have to repeat it over and over.


Cheers,

Tiago.

UserImage.jpg
Fábio Vaz
Solution

Charles Betman wrote:

Hi, I use the input_SetFocus widget to set the cursor in the SearchInput field together with an onfocus extended property to select the text already present in the input field. This works fine.

I wonder ... does OutSystems provide a more simple way (one statement or so) to achieve the same result?




Or Create an action with this Javascript:

(Call action RunJavaScript from HTTPRequestHandler Extension)

Input Param is your textbox


"osjs('#" + WidgetId + "').focus();"+ "osjs('#" + WidgetId + "').select();"


2014-10-21 20-15-17
Alberto Ferreira

Hello Charles Betman

The solution proposed Fábio Vaz  works and it deserve that you mark it as a solution. This way you can help others like me that had the same problem.


TIA

2020-04-29 14-31-37
Charles Betman

Alberto Ferreira wrote:

Hello Charles Betman

The solution proposed Fábio Vaz  works and it deserve that you mark it as a solution. This way you can help others like me that had the same problem.


TIA


Done Alberto ;)

2014-10-21 20-15-17
Alberto Ferreira

Thanks. 

UserImage.jpg
Sudhakar Dantanala

I need the same requirement but just not to select the text on focus instead need to show the cursor at end of the field. How can I do?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.