# Scroll to Top on Submit

**URL:** <https://forums.knack.com/t/scroll-to-top-on-submit/7601>\
**Category:** API & Custom Code\
**Created:** [July 8, 2016, 3:23pm UTC](https://forums.knack.com/t/scroll-to-top-on-submit/7601 "2016-07-08T15:23:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndySeger27892](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@AndySeger27892](https://forums.knack.com/u/AndySeger27892)\
**Post date:** [July 8, 2016, 3:23pm UTC](https://forums.knack.com/t/scroll-to-top-on-submit/7601/1 "2016-07-08T15:23:11Z")

</div>

On several of my pages, I have a table with a form below it to add entries to the table. Once the form is submitted, it is set to reload. When the form is submitted, the page scrolls down to the form, so the user cannot see the information added to the table in the prior submission without scrolling up.

I am trying to use java to scroll back to the top of the page upon form submission. I wrote the code below (I'm an amateur at this) that causes the page to scroll back to the top after the form is submitted, but then the page scrolls down to the form again.

Any ideas on how to stop this? THANKS!

  

```
$(document).on('knack-view-render.any', function(event, view, data) {
   $(".kn-submit input[type=submit]").on("click", function() {
      $('html, body').animate({
        scrollTop: 0
      });  
   });
});
```

---

<div class="post-metadata">

**Author:** ![ChrisWelch25535](https://avatars.discourse-cdn.com/v4/letter/c/eada6e/32.png) [@ChrisWelch25535](https://forums.knack.com/u/ChrisWelch25535)\
**Post date:** [November 9, 2016, 6:02pm UTC](https://forums.knack.com/t/scroll-to-top-on-submit/7601/2 "2016-11-09T18:02:00Z")

</div>

I have a similar problem - after a user submits a form, it directs to a different page. The page does not scroll to the top, though.
