I'm trying to generate a dynamic multiadd based off of variables gleaned from the URL. Basically I'm passing the product IDs into a webpage on my site so I can reassemble them into an order via multiadd. This is an attempt at a homemade invoicing feature.
So you use a URL like this to go to the invoice page: www.mysite.com/invoice.htm?prd1&prd2 etc.
A bit of javascript gleans the seperate product numbers and makes a URL for each product which is saved in an array. If I just statically create an array with a few URLs multiadd will work fine. When I dynamically generate the URLs then nothing happens. My test code is below. If you click on 'Click Me! 1' it will use the urlArray as it was instantiated. If you click on 'Click Me! 2' it generates the array from the product IDs passed and multiadd does not work. I have used EJEJC_lc in a function in a similar manner and that works fine.
Any tips would be most appriciated.
<html>
<head
<META NAME="Author" CONTENT="Jeffrey T. Birt">
</head>
<body>
<script language="javascript" type="text/javascript">
<!--
function EJEJC_lc(th) { return false; }
// -->
</script>
<script src='http://www.e-junkie.com/ecom/box.js' type='text/javascript'></script>
<script language="javascript" type="text/javascript">
<!--
var urlArray = ['https://www.e-junkie.com/ecom/gb.php?c=cart&i=CamBam-License&cl=56989&ejc=2','https://www.e-junkie.com/ecom/gb.php?c=cart&i=W9-SmStep&cl=56989&ejc=2'];
function getQueryVariables() {
var query = window.location.search.substring(1);
var vars = query.split("&");
//var urlArray = new Array();
if (vars.length > 1) {
for (var i=1;i < vars.length; i++) {
urlArray[i] = "https://www.e-junkie.com/ecom/gb.php?c=cart&" + vars[i]+ "&cl=56989&ejc=2";
document.write(urlArray[i] + "<br>");
}
//return EJEJC_multiAdd(urlArray);
}
return EJEJC_multiAdd(urlArray);
}
// -->
</script>
<br /><br />
<a href="https://www.e-junkie.com/ecom/gb.php?c=cart&cl=56989&ejc=2" target="ejejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);">
<img src="http://www.e-junkie.com/ej/ejview_cart.gif" border="0" alt="View Cart"/></a><br /><br />
<a onclick="javascript:EJEJC_multiAdd(urlArray);">Click Me! 1</a>
<a onclick="getQueryVariables()">Click Me! 2</a>
</body>
</html>
created
Jun '09
last reply
Jun '09
- 3
replies
- 675
views
- 2
users
- 9
links