View Full Version : Hip Hip Array....Not!

07-23-2006, 11:38 AM
Hi all, I'm having a problem after a variable is carried from one page to the next. Basically I have about 20 arrays in the page the variable is carried to, I now want to call on an array which has the same name as the variable carried. for instance:


Note: the function GetParam() returns the value of arraytouse (above), in this case, it should return "packA"

var packA = new array("pack A info","pack A price","pack A postage")
var packB = new array("pack B info","pack B price","pack B postage")
var packC = new array("pack C info","pack C price","pack C postage")

function GetParam(name)
var start=location.search.indexOf("?"+name+"=");
if (start<0) start=location.search.indexOf("&"+name+"=");
if (start<0) return '';
start += name.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result=location.search.substring(start,end);
var result='';
for(var i=start;i<=end;i++) {
var c=location.search.charAt(i);
result=result+(c=='+'?' ':c);
return unescape(result);

var product=GetParam('arraytouse')


Which I hoped would write "pack A postage", but instead returns "undefined" due to 'product' being a string and not equal to the array PackA :eek:

Can anyone help please??

Thanks in advance


07-23-2006, 01:13 PM