I am trying to debug the following code in Firebug. I keep on getting an error of:
multipleCartProductArray
ReferenceError: multipleCartProductArray is not defined
If i remove the “var” from before the array declaration i.e. multipleCartProductArray = new Array(); the error does not appear anymore. I thought i was declaring an array correctly? Anyone know whats going on here?
Thanks!
<script>
$(function() {
var cartProductObject = new Array();
cartProductObject = <?php echo $jsonProductsObject; ?>;
var multipleCartProductArray = new Array();
$.each(cartProductObject, function(cartProductKey, cartProductValues) {
multipleCartProductArray[cartProductKey] = parseInt(cartProductValues['product_quantity']);
});
$.each(cartProductObject, function(cartProductKey, cartProductValues) {
$('#productDate' + cartProductKey + '-' + multipleCartProductArray[cartProductKey]).on('change', function(){
checkValMatchString($(this), '<?php echo $this->_data['text']['selectDates_dropdownMenuTitle']; ?>', '.productDateError' + cartProductKey + '-' + multipleCartProductArray[cartProductKey], '<?php echo $this->_data['text']['systemError_requiredField']; ?>');
});
});
});
</script>