My cart is working almost the way I want. myfunction below returns the last item in the cart. I want to join the items in the array. I'm using alert() as a flag for myself to see if my array is working. Thanks for any suggestions. function myfunction(){ var mycart = new Array() JavaScript:top.MAIN.document.clientInfo.hideMessage.value = mycart for ( i=0; i<mycart.length; i++) alert(mycart) } function viewcart(){ for (i in shoppingCart) { cartTotal = cartTotal + shoppingCart.price if (shoppingCart.itemNum != null) shoppingCart.display(true, top.MAIN.document) mycart = new Array(shoppingCart.description +"..."+ shoppingCart.price ) } } <INPUT TYPE="button" onClick="JavaScript:top.HIDDEN.myFunction();" name="joe" value="Place Order">
You mean you want to literally join the values of the array together into one string ? also alert(mycart) ....
Yes, for every item the user clicks in adding to the cart I want to join together. The code works the way I want except for the second line in myFunction which returns a null value. I have changed the code from previous post to what you see now. I believe the null value is because the items passed to myFunction are not initialized, thus I receive the null error. I'm not sure how to initialize the array items in shopping cart passed to myFunction, or if I can even do that. for (i in shoppingCart) { cartTotal = cartTotal + shoppingCart.price if (shoppingCart.itemNum != null) shoppingCart.display(true, top.MAIN.document) myFunction(shoppingCart.description +"...$"+ shoppingCart.price + ".00") } function myFunction(theItems){ alert(theItems) JavaScript:top.MAIN.document.clientInfo.message.value = theItems }
ok, thanks. I will post the link soon. I will have the cart working with a cookie returning the data, or an asp script. I prefer to have variables and arrays doing the processing in javascript. I'll get back with you on this.