Title: Scroll down on click
Last modified: September 9, 2022

---

# Scroll down on click

 *  Resolved [asiry](https://wordpress.org/support/users/asiry/)
 * (@asiry)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/)
 * Is it possible to scroll down on click or whenever a question is answered? I 
   have built a form with hidden questions. So they will appear on the bottom. It
   would be nice when someone gave an answer and the next question pops, that the
   page scroll down to the question or just to the bottom.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fscroll-down-on-click%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-15995737)
 * Hi [@asiry](https://wordpress.org/support/users/asiry/)
 * I hope you are doing well.
 * Unfortunately, it is not possible, maybe to improve the user experience you can
   use the pagination: [https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#page-break](https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#page-break)
 * Best Regards
    Patrick Freitas
 *  [Aakash](https://wordpress.org/support/users/aakash8/)
 * (@aakash8)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-15996881)
 * Hi [@asiry](https://wordpress.org/support/users/asiry/)
 * Here’s a quick and dirty javascript solution that does the trick.
 * Add this javascript to any pages with the form:
 *     ```
       <script>
       function delay(time) {
         return new Promise(resolve => setTimeout(resolve, time));
       }
   
       const boxes = document.querySelectorAll('input');
         boxes.forEach(box => {
         box.addEventListener('click', function handleClick(event) {
           delay(500).then(() => window.scrollBy(0, 250, 'smooth'));
         });
       });
       </script>
       ```
   
 * And add this CSS to any pages with the form (or sitewide):
 *     ```
       html {
           scroll-behavior: smooth;
       }
       ```
   
 * Here’s how it looks in action: [http://recordit.co/v0fD41z2l7.gif](http://recordit.co/v0fD41z2l7.gif)
 * Hope this helped
 *  Thread Starter [asiry](https://wordpress.org/support/users/asiry/)
 * (@asiry)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004481)
 * Dear [@aakash8](https://wordpress.org/support/users/aakash8/)
 * I added the code, but it doesn’t work.
    Can you check if I did it right? ([https://caretix.nl/gezondheidstest/](https://caretix.nl/gezondheidstest/))
 * [@wpmudevsupport12](https://wordpress.org/support/users/wpmudevsupport12/) Thank
   you for your fast response.
 *  [Aakash](https://wordpress.org/support/users/aakash8/)
 * (@aakash8)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004756)
 * [@asiry](https://wordpress.org/support/users/asiry/)
 * I’m seeing an error that the const/variable `boxes` is already being used elsewhere
   on you site. Try this instead:
 *     ```
       <script>
       function delay(time) {
         return new Promise(resolve => setTimeout(resolve, time));
       }
   
       const forminator_boxes = document.querySelectorAll('input');
         forminator_boxes.forEach(box => {
         box.addEventListener('click', function handleClick(event) {
           delay(500).then(() => window.scrollBy(0, 250, 'smooth'));
         });
       });
       </script>
       ```
   
 *  Thread Starter [asiry](https://wordpress.org/support/users/asiry/)
 * (@asiry)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004832)
 * [@aakash8](https://wordpress.org/support/users/aakash8/)
 * I am grateful for your time. Thank you.
 * It is still not working.
 *  [Aakash](https://wordpress.org/support/users/aakash8/)
 * (@aakash8)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004870)
 * [@asiry](https://wordpress.org/support/users/asiry/)
 * No problem.
    The error is gone now, I think we just need to run the script after
   page load now.
 * Try:
 *     ```
       <script>
       window.onload = function () {
           function delay(time) {
               return new Promise(resolve => setTimeout(resolve, time));
           }
   
           const forminator_boxes = document.querySelectorAll('input');
           forminator_boxes.forEach(box => {
               box.addEventListener('click', function handleClick(event) {
                   delay(500).then(() => window.scrollBy(0, 250, 'smooth'));
               });
           });
       };
       </script>
       ```
   
 * Have to sign off for now, hopefully this does the trick! Otherwise someone will
   get back to you. Good luck.
 *  Thread Starter [asiry](https://wordpress.org/support/users/asiry/)
 * (@asiry)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004907)
 * [@aakash8](https://wordpress.org/support/users/aakash8/)
 * Now it works 🙂
 * Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Scroll down on click’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [asiry](https://wordpress.org/support/users/asiry/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/scroll-down-on-click/#post-16004907)
 * Status: resolved