[thelist] PHP Jump to Anchor Tags?

Simon Coggins ppxsjc1 at nottingham.ac.uk
Thu Oct 11 12:52:16 CDT 2001

> > window.location="#anchor"
> >
> > ...would work.
> Yes, it would.  However I do not have the option of using JS on this
> project.  It is php embedded in html.  php script is doing field validation
> and I need to have php script relocate to an anchor (in same page) if there
> are errors to be corrected on a form.

So PHP is validating the form info then you want to either display a
'that worked' page or a 'that didn't work try again' page. I can think of
two approaches:

1. Make the action of the form point to some intermediate script that does
the validation then do a php redirect to either the results page or the
first page with the anchor included.

2. Make the whole form one .php file and decide what to display based on
which variables are defined (e.g. $HTTP_POST_VARS["submit"] if the submit
button has is named submit). Make the action of the form point to the

<form action="<?php=$PHP_SELF?>#anchor" method="post">

if the validation is successful then the #anchor won't be used, otherwise
it will.

I prefer (2), because option (1) will disable the back button. 

I hope this is clear. If not ask and I'll try to be more eloquent.


More information about the thelist mailing list