Focusing a form element on page load

I’m trying to get the first field in my form to automatically focus when the page loads. I’ve not found a tick box for this, so I’ve tried to do it by going to app properties and creating a dynamic event for when my app loads to set the focus on the element. This doesn’t seem to work though, so to test it I tried to show a browser alert on page load but this doesn’t seem to be working either.

Have I missed a key step out here to get this working?

Many thanks,

Neil

I don’t think there is a way to do it in Wappler (meaning ‘I haven’t tried’) :wink:

But here . is how to do it by adding some simple code to your body tag …

https://www.mediacollege.com/internet/javascript/form/focus.html

1 Like

HTML5 has an autofocus attribute (https://www.w3schools.com/tags/att_input_autofocus.asp). In Wappler you can add it using the DOM panel.

2 Likes

Well, Whaddya know. There is a way and it works pretty dang slick. lol

Found it! And working well :slight_smile: Thanks Patrick!

1 Like

I beat you to it @Patrick but only by 3 hours, my login video already explained the auto focus and tab index properties in the DOM. Lol. Actually rethinking this I could not have really beat you to it considering you were probably the guy that coded autofocus in the DOM in the first place. So sad.

1 Like