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"HTML Code:mypage.htm?arraytouse=packA
Which I hoped would write "pack A postage", but instead returns "undefined" due to 'product' being a string and not equal to the array PackACode: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') document.write(product[2])![]()
Can anyone help please??
Thanks in advance
Chris



Reply With Quote

Bookmarks