PDA

View Full Version : forms and page anchors : possible?


drewprops
2006-01-18, 22:44
I'm working on a form that's located at the bottom of a page and have used an HTML anchor (<a name = "contact">) to "bounce" the visitor down to where that form is located. But, after the user makes their entries and clicks the 'SEND' button I want to send them BACK down to that very same area for results... but I can't because the pound/number sign which serves as the anchor does not survive the reload of the page. In the URL it comes back as a %23 instead of as # and that just doesn't seem to work. I know that this is correct behavior for a browser but is there any way to get this to work? If so, what am I missing?

I await someone's perspicacity.


echo "<input type=\"hidden\" name=\"foo\" value=\"bar#contact\">";

rollercoaster375
2006-01-18, 23:00
<!--All that HTML goodness-->
<form action="foo.php#contact">


From what I understand, that's all you need, unless you're using XMLHTTPRequest, or a redirect.

If you're using a redirect, just point it to that URL.

drewprops
2006-01-18, 23:09
PERFECT!

I couldn't get this part

action=\"index.php?sec=about#contact\"


to work right, hence I switched to the attempt shown in my first post of this thread. Now I'm just splitting the info up and it works right!

Now I just toss in a hidden field to send the "section" variable

echo "<input type=\"hidden\" name=\"sec\" value=\"about\">";

and it all works great!

EDIT: Yes, I'm working in PHP.

rollercoaster375
2006-01-19, 11:42
The only reason I could see that it might be doing that, would be if you're doing a html_entities call on the Output buffer...

Just, if you wanted to know a possible cause.