Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:07
Moving data between pages
Poster: im-press
Dated: Friday October 3 2003 - 17:35:23 BST
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?subject=Hand%20Polished%20-%20Sandblasted%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
Poster: Hergio
Dated: Saturday October 4 2003 - 21:05:39 BST
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:
<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>
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:
<td>
Thanks for your interest in <span id="interestedItem"></span>
<SCRIPT>
queryKeys = getKeys();
document.all["interestedItem"].innerHTML = queryKeys["something1"];
</SCRIPT>
</td>
Good luck.
Thanks for your interest in <span id="interestedItem"></span>
<SCRIPT>
queryKeys = getKeys();
document.all["interestedItem"].innerHTML = queryKeys["something1"];
</SCRIPT>
</td>