Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    How to submit form to auto scroll to bottom of page

    Hi, hopefully a simple one, I have lots of items on a page and a mail form that submits these items. Problem is every time you hit submit it scrolls to the top of the page, which does not allow the user to view errors or successful submission message. How can I make the submit stay at the bottom of the screen once submitted?

    Thanks

    Eddie

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New Coder
    Join Date
    May 2008
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks for your response, but I'm not sure how I can add this answer to my form i.e

    Posting of the form

    Code:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
    Submitting of the form


    Code:
    <input type="hidden" id="submitted" name="submitted" value="1">
    <input type="submit" class="vpb_general_button" value="Submit">
    Thanks

    Eddie

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    OK try this:

    Code:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>#button" enctype="multipart/form-data">
    and

    Code:
    <input type="submit" class="vpb_general_button" id="button" value="Submit">
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • Users who have thanked whizard for this post:

    Eddie_E (07-01-2013)

  • #5
    New Coder
    Join Date
    May 2008
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Ok this works :-)

    Thanks

    Eddie

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    For the sake of education of anyone who doesn't know, this works because you can link to an ID anywhere on the page

    Code:
    <body>
     <section id="contents">blah blah blah</section>
     <section id="essay">blah blah blah</section>
     <section id="footnotes">blah blah blah</section>
    </body>
    <a href="thispage.html#footnotes">Footnotes</a>

    When you submit a form, even if you submit it to itself, the URL set in the form's action element is loaded. This causes the top of the page to be shown.

    HTH
    Dan
    Last edited by whizard; 07-01-2013 at 05:15 AM.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •