Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
como reutilizar una variable con todo y su valor en otra pagina de mi proyecto

estoy trabajando en un comercio electrónico y estoy tratando de hacer la página donde llenas tu información, pero no puedo usar mi carrito variable, o mi total.textContent solo necesito mostrar mi carrito, el total del carrito y mi formulario pero no puedo usar ninguna de mis variables o funciones

enter code here

 const container = document.getElementById("container"); const cartContainer = document.getElementById("cart-items"); let cart = []; export let stock = [ {id: 1, item: "Playera blanca - Logo rojo", precio: 265, imagen: '<img class="cart-review-img" src="./images/Playera blanca - Logo rojo.png" alt="">' }]; const upDateCart = () => { cartContainer.innerHTML = "" cart.forEach((prod) => { const div = document.createElement("div") div.className = ("cart-review-cotainer") div.innerHTML = ` <div class="cart-image col-md-5"> ${prod.imagen} </div> <div class="col-md-5 d-flex flex-column justify-content-between"> <div> <p id="cart-item-name">${prod.item}</p> <p id="cart-item-price">${prod.precio}</p> </div> </div> <div class="col-md-2 delete-container"> <button onclick="deleteItem(${prod.id})" id="delete-item"><img class="delete-img" src="./images/trash-solid.svg" alt=""></button> </div> ` cartContainer.appendChild(div) localStorage.setItem("newCart", JSON.stringify(cart)) }) total.innerText = cart.reduce((acc, prod) => acc + prod.precio, 0) } if(localStorage.getItem("newCart")) { newCart = JSON.parse(localStorage.getItem("newCart")) console.log(newCart) upDateCart() } window.deleteItem = deleteItem; window.cart = cart; window.test = test; window.newCart = newCart;

mis archivos en código vs

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No pude ejecutar tu fragmento, pero supongo

 if(localStorage.getItem("newCart")) { newCart = JSON.parse(localStorage.getItem("newCart")) console.log(newCart) cart = newCart; // 👈 add this line maybe? upDateCart() }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!