Moving data between pages

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
im-press
Beginner
Beginner
Posts: 9
Joined: Mon Sep 15, 2003 2:00 pm
Location: Hastings, England
Contact:

Moving data between pages

Post by im-press »

Hi,

I am using the v5 menu system and I want to pass a description from a product page to a quote page so the user does not have to retype the product description. I have looked at options using "cgi" and "asp" but I have seen an example using "js" with "var=url" in the first page setting the variable with the required data and then using "location.search" in the second page to pick up the data.

Code Goes like this;
Sending Program:
<head>
var url = 'www.im-press.co.uk/quick_quote.htm?subj ... d%20Badges'
</head>
<body>
<A HREF="javascript:NewWindow('url','Quote','450','450','no')">

Receiving Program:
<% descript=Request.QueryString( "subject") %>
<html>
<head>
<body>
<p>Thanks for your interest in <B><%=descript%></B>.<BR>


I have tried different variations but so far have failed, my "js" is not good so does anyone know if (a) is this possible with the menu system or (b) is there a better way?

Regards
Ian
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

The example you used uses ASP, which you said you are not using. Try this function in the receiving page. Say you have a link in the menu, page.html?something1=value1&something2=value2

Put this in the HEAD of your document

Code: Select all

<SCRIPT>
function getKeys() 
{ 
   var keys = new Object(); 
   var queryString = location.search.substring(1); 
   var keyPairs = queryString.split("&"); 
    
   for(var i = 0; i < keyPairs.length; i++) 
   { 
      var position = keyPairs[i].indexOf('='); 
        if (position == -1) continue; 
       
       var keyname = keyPairs[i].substring(0, position ); 
       
       var keyvalue = keyPairs[i].substring(position + 1); 
       keys[keyname] = unescape(keyvalue); 
   } 
   return keys; 
    
  } </SCRIPT>
In the receiving page, to get the value1 that was set to something1, and you want to display value1, you'd say...

Code: Select all

<td>
Thanks for your interest in <span id="interestedItem"></span>
<SCRIPT>
queryKeys = getKeys();
document.all["interestedItem"].innerHTML = queryKeys["something1"];
</SCRIPT>
</td>
Good luck.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
im-press
Beginner
Beginner
Posts: 9
Joined: Mon Sep 15, 2003 2:00 pm
Location: Hastings, England
Contact:

Post by im-press »

Dave,

Thanks for this, you just stopped me going premeturely grey.

Once again thanks for this.

Regards
Ian
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Did it work? Let me know how it goes? Hey, you're very welcome! :D
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply