I have a form that on submit refreshes the page and shows the errors.I just need it to scroll back to the form.This is the form tag:
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
This is the function:
function GetSelfScript()
{
return htmlentities($_SERVER['PHP_SELF']);
}
How do I add the #contact to the function?
Thanks!
You don't need php here. Append the id of the element you want to jump to as an anchor to the action field.
e.g.
<form id="contactUs" action="target.php#contactUs" />
in your case (whatever is appropiate)
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>#contactus' method='post' accept-charset='UTF-8'>
or
function GetSelfScript($anchor = null)
{
$anchor = $anchor === null ? '' : '#' . $anchor;
return htmlentities($_SERVER['PHP_SELF']) . '#' . $anchor;
}
and
<form id='contactus' action='<?php echo $formproc->GetSelfScript("contactus"); ?>#contactus' method='post' accept-charset='UTF-8'>