Hi guys!

I need some help with setting the focus to an input field in a Reactive app. I want to set the focus to a specified input during a Client action. I could not find an equivalent for the Input_SetFocus action, so I tried using using a JavaScript action, but I cannot seem to get the syntax right... I am trying to use something like:

"$(""#" + SpecifiedInput.Id + """).focus()"

However this does not seem to be working... I suspect my syntax is broken, but none of the variations I have tried work.

Any advice / pointers would be appreciated!

Hi Chris,

Yes, your syntax is incorrect. This is pure javascript code, so there's no need to wrap it in double quotes (""). Also, you need to pass in the input's Id as a parameter to the javascript block.

Solution

Also, I see that you're using jQuery for that. If you already have it in your app, then that's fine. Otherwise, it might be overkill to add it just to accomplish this. You could do it with plain javascript with something like:

document.getElementById($parameters.InputId).focus();
Solution

Thanks Aurelio!

The plain JavaScript worked perfectly!