Results 1 to 3 of 3

Thread: Need to populate a form hidden field with the URL of the referring page

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need to populate a form hidden field with the URL of the referring page

    (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.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    I don't believe that Javascript has access to that information

  3. #3
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default

    If the URL is seen in the address bar then yes yo can do it.

    Code:
    <HTML>
    <HEAD>
    <SCRIPT type="text/javascript">
    	function getQuerystrings(inputId) {
    
    		var urlString = parent.document.URL;
    		var queryString = urlString.substring(urlString.indexOf('?'),urlString.length);
    		
    		//test
    		alert(urlString+"\n"+queryString);
    		
    		inputObj = document.getElementById(inputId);
    		inputObj.value = queryString;
    		
    		//test
    		alert(document.getElementById(inputId).value);
    		
    	
    	}
    </SCRIPT>
    </HEAD>
    <BODY>
     <form id="form1">
     <input id="urlQuery"  type="hidden" value="">
     <input type="button" value="Check" onclick="getQuerystrings('urlQuery')">
     </form>
    </BODY>
    </HTML>

    See to get it working http://www.webmasterworld.com/forum91/216.htm
    Last edited by Bob90; 03-15-2008 at 01:20 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •