On Focus funtion using java script

I have a page where I have button with caption "AddObservation".  When the button is clicked  a form is generated on the top of button in the same page. Like wise, no. of times the button clicked as many forms will be generated above the button. My problem is when I click on the button I am able to see the bottom of the form, but I need to focus on the top of the form. I have already written a java script function to focus on the top, but it is not happening as the js is executing before the form is loaded. Do we have any solution for this. The form generated is not a new page, it is in the same page. 
1 answers

If the form generated by pressing the button refreshes a data view of that page, then you can put your js in a javascript snippet widget and select refresh on context change. The placement of this widget will need to be in the data view that is being refreshed. The widget should automatically run the js after everything is loaded.
Widget: https://appstore.home.mendix.com/link/app/43096/Incentro-Business-Acceleration/JavaScript-Snippet