Re: Moving to an anchor in PHP script
| From: | Claude Cormier | Date: | Thu, 24 Aug 2000 22:10:17 +0000 |
| Subject: | Re: Moving to an anchor in PHP script | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13535@lists.php.net to get a copy of this message | ||
Hello Dean, thanks for replying...
Well using an .html page can't work for me as I have dynamic graphics
from a MySQL db in this PHP script... so if I want to change my graphics
depending on the topic selecled, I cannot redirect to something like
""http://www.yoursite.com/page.html#whatever"
So I guess I can't use anchors within a PHP script? Am I right or I
don't understand?
Dean Hall wrote:
>
> > I have a script which generate a dynamic page. Among other things, I
> > have several anchors (such as <A name="intro></A>) in front of different
> > topics. Using a form with the post method I have a topic selector which
> > I want to use so it will branch to the selected topics.
> >
> > A typical <option> within this form would look like:
> >
> > <option value="#intro">1. It's time for e-commerce</option>
> >
> > Can this be done within the script? How can I control the positioning of
> > the page at the selected anchor?
>
> According to < http://zend.php.net/FAQ.php#7.14 >, in a
> <select> tag with
> single selection, the name of the <select> tag is given the value of the
> selected option. So if you have:
>
> <SELECT NAME="options" SINGLE> <!-- I think this is how you specify a single
> selection. -->
> <OPTION value="#intro">It's time for e-commerce.</OPTION>
> <OPTION value="#conclusion">Time for e-commerce is over.</OPTION>
> </SELECT>
>
> and I choose the first option, and then you do the following in the PHP
> form-handler:
>
> echo $HTTP_POST_VARS[options];
>
> you'll get "#intro" printed out.
>
> So, my best idea of how to redirect the user to the appropriate page would
> be to do the following in your PHP form-handler (untested):
>
> header("Location: http://www.yoursite.com/page.html"
> .
> $HTTP_POST_VARS[options]);
>
> But for this you'd probably have two different pages -- one to handle the
> form POST action, and one that you want to send the user to.
>
> Or...
>
> You could use Javascript (untested):
>
> <SCRIPT LANGUAGE="JavaScript">
> function sendUser() {
> document.location = "http://www.yoursite.com/page.html"ëwé У
> ˜ÁÈ!´ +
> document.forms[myForm].elements[options].selectedIndex;
> }
>
> <FORM ONSUBMIT="sendUser()" NAME="myForm">
> ... <!-- options here -->
> </FORM>
>
> My JavaScript's rusty as hell, and you may want to consult the DOM that's
> really implemented in each browser to keep it cross-browser. Of course, my
> first thought, the server-side implementation with a form-handler would rid
> you of having to rely on a browser to do the right thing.
>
> Hope this helps. :-)
>
> Dean.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net