By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,745 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,745 IT Pros & Developers. It's quick & easy.

Jump to section of same page

P: n/a
TG
Dear PHP Group,

How can I in PHP, based on a result, move the cursor to a certain location
on the page? I want the same result as Anchor tags in HTML. I want to go to
a certain section of the same page based on a return result in PHP. What
this is for is an order forms page - when a user fills out a section
incorrectly, I want the page to display at that location in the form after
the user presses a submit button.

How do I do this?

Thanks,
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
TG schrieb:
How can I in PHP, based on a result, move the cursor to a certain location
on the page?
You can't. PHP is running on the server and when the browser displays
your page, the PHP script is long gone.
I want the same result as Anchor tags in HTML. I want to go to
a certain section of the same page based on a return result in PHP. What
this is for is an order forms page - when a user fills out a section
incorrectly, I want the page to display at that location in the form after
the user presses a submit button.


Then use HTML anchors.

Regards,
Matthias
Jul 17 '05 #2

P: n/a
TG
Matthias,

In this particular case a submit button is pressed the page is
self-referential so the check can occur afterwards and perform an action on
the same page (for example I have PHP code to check a users input on an
order form -- based on a PHP check I can run this check and have a result
occur on this same page). An HTML anchor must be pressed to navigate to a
page location I believe, unless you know a way to force it to occur without
user input.
"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:cb**********@usenet.esken.de...
TG schrieb:
How can I in PHP, based on a result, move the cursor to a certain location on the page?


You can't. PHP is running on the server and when the browser displays
your page, the PHP script is long gone.
I want the same result as Anchor tags in HTML. I want to go to
a certain section of the same page based on a return result in PHP. What
this is for is an order forms page - when a user fills out a section
incorrectly, I want the page to display at that location in the form after the user presses a submit button.


Then use HTML anchors.

Regards,
Matthias

Jul 17 '05 #3

P: n/a
TG schrieb:
In this particular case a submit button is pressed the page is
self-referential so the check can occur afterwards and perform an action on
the same page (for example I have PHP code to check a users input on an
order form -- based on a PHP check I can run this check and have a result
occur on this same page). An HTML anchor must be pressed to navigate to a
page location I believe, unless you know a way to force it to occur without
user input.


OK, I see the problem.

You could use header() to make a second redirection to the same page
after the check shows an error. In this redirection you would add the
anchor.

The drawback is, that you have to transport the data from the first to
the second call and you have to perform the check twice. Maybe there's a
solution with JavaScript - for those browsers which have JavaScript
enabled.

Matthias
Jul 17 '05 #4

P: n/a
TG
Thanks, I'll try that.

"Matthias Esken" <mu******************@usenetverwaltung.org> wrote in
message news:cb**********@usenet.esken.de...
TG schrieb:
In this particular case a submit button is pressed the page is
self-referential so the check can occur afterwards and perform an action on the same page (for example I have PHP code to check a users input on an
order form -- based on a PHP check I can run this check and have a result occur on this same page). An HTML anchor must be pressed to navigate to a page location I believe, unless you know a way to force it to occur without user input.


OK, I see the problem.

You could use header() to make a second redirection to the same page
after the check shows an error. In this redirection you would add the
anchor.

The drawback is, that you have to transport the data from the first to
the second call and you have to perform the check twice. Maybe there's a
solution with JavaScript - for those browsers which have JavaScript
enabled.

Matthias

Jul 17 '05 #5

P: n/a
"TG" <tg********@cox.net> wrote in message
news:Mm1Bc.10138$cj3.8582@lakeread01...
Dear PHP Group,

How can I in PHP, based on a result, move the cursor to a certain location
on the page? I want the same result as Anchor tags in HTML. I want to go to a certain section of the same page based on a return result in PHP. What
this is for is an order forms page - when a user fills out a section
incorrectly, I want the page to display at that location in the form after
the user presses a submit button.

How do I do this?


Since it's not a critical function, I would just use Javascript to set the
focus on the input field. Something like this at the end of the script would
work:

echo "<script> document.getElementById('phone').setFocus(); </script>";
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.