I have a form on a PHP page :
<form name="SendEmail01" method="post">
form items here...
</form>
I then process it like this:
if(isset($_POST["Submit"]))
{
All tasks here...
$thanks_redirect = 'http://' . $_SERVER["SERVER_NAME"] . '/thanks.php#top';
header("location: $thanks_redirect");
}
The issue is that the submit button on the processing page is quite low down on the page and when I press 'Submit' it all processes correctly and jumps to the thanks.php page correctly, but the page stays in the same location and it looks like its just a blank page (unless the user scrolls up).
I have tried Javascript and HTML hyperlinks such as #top but it will just not jump back to the top of the page where, on the thanks.php page, it says that it has all been processed correctly.
Could anyone please help with how I get the thanks.php page to scroll back to the top of the page once the form has been processed?
Edit : I have this on the thanks.php page where the user is redirected on submission:
<html>
<head>
<script type="text/javascript">
var lockit=setInterval("window.scrollTo(0,0)",10)
</script>
<style>
form {
display: inline;
}
input
{
color: #000000;
background: #ffffff;
border: 1px solid #000000;
padding: 4px;
font-size:13px;
font
}
#submit {
color: #000000;
font-size: 13px;
width: 110px;
height: 30px;
border: 1px solid #000000;
margin: 0;
padding: 0;
background: #66ff66 url(image) 0 0 no-repeat;
}
#buttons {
color: #000000;
font-size: 13px;
width: 80px;
height: 25px;
border: 1px solid #000000;
margin: 0;
padding: 0;
background: #66ff66 url(image) 0 0 no-repeat;
}
</style>
</head>
<body>
<script type="text/javascript">
$('html, body').animate({ scrollTop: 0 }, 'fast');
</script>
<?php
session_start();
$loggedin_user = $_SESSION['serial'];
$local_path = $_SESSION['local_path'];
$full_path = $_SESSION['full_path'];
?>
<font face="Verdana, Arial, Helvetica, sans-serif" color="black">
<form action="http://<?php echo $_SERVER["SERVER_NAME"]; ?>/login.php?log_out">
<input type="submit" value="Logout" id="buttons">
</form>
<form action="<?php echo $full_path;?>index.php">
<input type="submit" value="Go Back" id="buttons">
</form>
<p><b>Success!</p></b>
<p>Your changes have been submitted..
<p>Please note that not <u>all</u> changes are made in real-time, some changes may only be updated when the server checks for new configuration.</p>
</body>
</html>
Thank you.
I'd add this as a comment, but it's a bit too long for it.
I made this page:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Calibri Text</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<form>
<input type="submit" />
</form>
</body>
</html>
On submission, the page jumps to the top along with a redirect to another page, so you shouldn't be having this issue less there is something in your jQuery giving something focus.
Try this.
$('html, body').animate({ scrollTop: 0 }, 'fast');
You don't need any custom divs
for this. Just have a simple page.
<html>
<head>
<title>Thanks Page</title>
</head>
<body>
Well Thanks bro!
</body>
</html>