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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get url of previous page and submit in a form

Status
Not open for further replies.

Katie6

Programmer
Jun 12, 2007
58
GB
Hi there,

I have a button to a feedback form on every page on my site. The problem is that if users make a comment about a page, I can't tell what page they're talking about.

I would like to add a hidden form field on my feedback form where the value is the url of the previous page (therefore I'll know what page they've come from!). Does anyone know how to do this? I tried this:

Code:
<input type="hidden" name="q5" id="PageURL" onsubmit="document.getElementById('PageURL').value = history.go(-1);">

...but this doesn't work, and being a wally, I'm probably on completely the wrong track! :(

Many thanks,

Katie
 
You can't access the history object to do that.

Why not add a GET parameter to the URL on each page (done via javascript if you can't get the back-end to do it for you). Then you pick up on the GET parameter on your feedback page - and have the backend populate the hidden field when it delivers the page (or you can use javascript to pick it out for you).

Does this sound like it would work for you?

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Hmmm, that'll explain why mine didn't work!
Yes, I'll give that a go - thanks Jeff :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top