js/catalog.js
// TODO: As you add items into the cart, show them (item & quantity) in the cart preview div
As you add items into the cart, show them (item & quantity) in the cart preview div
As you add items into the cart show them ( item & quantity ) in the cart preview div
function updateCartPreview() {
  let list = document.getElementById('items');
  let itemPickedIndex = list.selectedIndex;
  let itemPicked = list.options[itemPickedIndex].text;
  let quantity = document.getElementById("quantity").value;
  const parentElement = document.getElementById( 'cartContents' );
  const ulElement = document.createElement( 'ul' );
  parentElement.appendChild( ulElement );
  const liElement = document.createElement( 'li' );
  ulElement.appendChild( liElement );
  const img = document.createElement('img');
  img.setAttribute('width','80px');
  for (let i =0; i < Product.allProducts.length;i++){
    if (Product.allProducts[i].name === itemPicked){
      img.src = Product.allProducts[i].filePath;
    }
  }
  ulElement.appendChild(img);
  liElement.textContent = `You picked ${quantity} of this product --> ${itemPicked}`;
}
function updateCartPreview ( ) { let list = document . getElementById ( 'items' ) ; let itemPickedIndex = list . selectedIndex ; let itemPicked = list . options [ itemPickedIndex ] . text ; let quantity = document . getElementById ( "quantity" ) . value ; const parentElement = document . getElementById ( 'cartContents' ) ; const ulElement = document . createElement ( 'ul' ) ; parentElement . appendChild ( ulElement ) ; const liElement = document . createElement ( 'li' ) ; ulElement . appendChild ( liElement ) ; const img = document . createElement ( 'img' ) ; img . setAttribute ( 'width' , '80px' ) ; for ( let i = 0 ; i < Product . allProducts . length ; i ++ ) { if ( Product . allProducts [ i ] . name === itemPicked ) { img . src = Product . allProducts [ i ] . filePath ; } } ulElement . appendChild ( img ) ; liElement . textContent = ` ${ quantity } ${ itemPicked } ` ; }
TODO: As you add items into the cart, show them (item & quantity) in the cart preview div
TODO : As you add items into the cart show them ( item & quantity ) in the cart preview div
// TODO: Get the item and quantity from the form // TODO: Add a new element to the cartContents div with that information