Thank you that, making or declaring array global did the trick.
However, when i do a sort() i'm not getting a matching list/array - 'items' are not matching 'quantity', currently 'item' array & 'quantity' array are different. Where am i going wrong? see my code:
- var c=[]; //item array
-
var d=[]; //quantity array
-
-
function letsShop() {
-
-
var item=document.getElementById("item").value;
-
var quantity=document.getElementById("quantity").value;
-
-
c[c.length]=item;
-
d[d.length]=quantity;
-
-
Basket_display(item,quantity);
-
}
-
-
-
function Basket_display(item,quantity) {
-
document.getElementById('display').innerHTML+=item + " X "+ quantity+'<br>';
-
}
-
</script>
I think i need to 'join' the two arrays together, not sure how to do this?