This topic is locked
[SOLVED]

 Set focus and select contents

7/23/2018 4:28:12 PM
ASPRunner.NET General questions
T
Tim author

Hello,
When editing in popup window, can I set the focus to a field AND have the contents selected when the page loads? I've tried using the setFocus 'JavaScript OnLoad' event (see the code below) and this code only sets the focus, but does not select the existing text/number in the field.
var ctrl = Runner.getControl(pageid, 'Quantity');

ctrl.setFocus();
Then I tried using ctrl.select(); // still didn't select the text in field.
I've also tried giving the field an id (ID="myText") and added the code below into JavaScript OnLoad, but that didn't work either.
var input = document.getElementById('myText');

input.focus();

input.select();
Thanks for any help.

Tim

admin 7/24/2018

Try this in Javascript OnLoad event of the page in question:

$("input[id^=value_File]").select().focus();


Here "File" is the field name.

T
Tim author 7/24/2018

That's it! Thank you!