Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a bookmark to a form submission 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
0
0
GB
I am familiar with appending a bookmark to a URL to direct a browser to an area of the page.

Code:
[URL unfurl="true"]http://www.mysite.co.uk/cgi-bin/myscript.cgi?pocode=ABC[/URL] 123#baskit

Is it possible to get the same functionality from a form submission?

I tried adding the bookmark as a hidden var but the browser changes the hash is to it's character number (%23) and treats the bookmark as simple text.

Code:
<form action = 'audio2u.cgi'>
<input type='text' name='pocode' value=''>
<input type='submit' name='call' value='Change Postcode'>
[COLOR=#EF2929]<input type='hidden' name = 'lnk' value='#baskit'>[/color]
</form>

Keith
 
The browser isn't changing it, the HTTP request mechanism is. Your server side code needs to convert the URLEncoded characters as it concatenates the final URL.

The space in "Change Postcode" will be changing to a %20 as well,

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Why not just add it directly to the form's action.

Code:
<form action = 'audio2u.cgi#baskit'>

That is assuming that audio2u.cgi generates a valid html page. With an anchor named baskit somewhere in it.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Does this mean that YOU added the hidden field (not just the value) to the form expecting it to do something??

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks Phil, that's the answer, why didn't I think of that - doh!

Chris, it was experiment time.
Adding the hidden field put the value on the end of the query string but of course, as you said, it needed to be URL encoded. Putting #baskit on the end of the query string triggers the bookmark.

The answer was quite obvious in the end.

Thanks guys.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top