View Full Version : Need to populate a form hidden field with the URL of the referring page

03-14-2008, 04:56 PM
(I'm not a real programmer, I don't even play one on TV).

Here's the set-up:

I have a link (Review This Product) on a page that is going to launch a daughter window (via thickbox if that matters) that contains the review form.

On this product review form there will of course be a bunch of review parameters, but one thing I need to pass is the URL (actually the tail end of the URL that contains the product's ID (i.e. &id=FOO I parse out the part after the =)) in a hidden field.

How could/should this be done?

Should I use javascript to append the parent page's URL to the link that launches the daughter window, or should I use some kind of javascript call that can bring up the referring link's page? (and what would that be or look like)

Any help would be greatly appreciated.

03-14-2008, 07:06 PM
I don't believe that Javascript has access to that information

03-15-2008, 01:09 PM
If the URL is seen in the address bar then yes yo can do it.

<SCRIPT type="text/javascript">
function getQuerystrings(inputId) {

var urlString = parent.document.URL;
var queryString = urlString.substring(urlString.indexOf('?'),urlString.length);


inputObj = document.getElementById(inputId);
inputObj.value = queryString;


<form id="form1">
<input id="urlQuery" type="hidden" value="">
<input type="button" value="Check" onclick="getQuerystrings('urlQuery')">

See to get it working http://www.webmasterworld.com/forum91/216.htm