Cursor Focus on Input Field

When a page loads, I’d like to set the cursor in the first input form field. I tried to set focus to the field on page load, but it didnt seem to work. How can I get this to display?

Thanks

That should work. OnPageLoad Set Focus on widget name

If it’s not for whatever reason, could you upload your axure file so someone can work out why it isn’t working?

I did more troubleshooting and think I found the problem.

Per MSDN the “set focus” sets the keyboard focus to the specified window. The window must be attached to the calling thread’s message queue. This seems to me that the set focus is the wrong parameter.

However, I was able to update the input in HTML code by adding:

autofocus=“autofocus”

e.g.

<input id=“u10_input” type=“text” value="" autofocus=“autofocus” data-label=“cursorfocus”/>

Hi all - There should never be a need to modify code to do something like this. See attached file and let me know if it doesn’t work for you.
setfocus-onpageload.rp (47.4 KB)

This works, but it should always be Case 1. I had another onload condition that I had made as Case 2 so it didnt display. When I set the focus to the input box as the first case then it worked. Thanks

When using OnPageLoad, you can’t do multiple cases unless you are using conditions. Usually the multiple case scenario works when you’re clicking a button and then you have the option to choose which case you want to fire. When using OnPageLoad you will never get the chance to choose which Case will fire.

1 Like

is there a way to do this without on page load? Can I do this after switching to a new dynamic panel state and have it auto focus on the input field? thanks!

never mind i found it, it’s actually there i was just blind : p

Hello,

I’m trying to keep the blinking cursor visible when the search bar is shown from it’s hide state and I can’t seem to figure it out. I can get it to focus, but then the cursor disappears. Anyone know what’s going on :slight_smile:

Here is the file:
Mills Menu Prototype_2.rp (1.14 MB)

Sorry to hijack this thread, but I have the same problem, my cursor does not display within the input field on focus. How can I get it to show?

Hi Saraettawow,

Are you putting the focus with OnPageLoad or another interaction? If you’re using conditional logic to set focus on the input field with OnPageLoad, make sure the conditional case that’s setting the focus is getting evaluated to true. You can check which cases get fired by looking at the Console tab of the HTML sidebar with RP 8, here:

If that checks out, feel free to post your RP file here and I’ll be happy to take a closer look to see what’s preventing the input field from getting focused. Thanks!

I have the same problem as well… I do have the set focus on textfield and it does fire… the problem is that I have a very complex file and 10 other on load interactions before that one. The weird thing is that the “field” is selected… but the cursor is not “blinking”… could this be because I created a “custom” textfield by having a transparent rectangle, and I am putting on focus the textfield?

Hi nicolebtesh,

Hmm, it’s a bit hard to say without having the file - would you be able to post that here so that I could take a closer look? If you’d rather keep the file private, please feel free to send that over to support@axure.com. Ty!