Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
Value from Session Storage as a number?

I have two values on my html: "Money" and "Time", and those values come from Session Storage, depending on what the person filled previously in another html page. So lets say the person filled that they need to pay $100 in 2 days.

So the idea would be for the result to be displayed on my HTML like:

  • $50
  • $50

If the number of days increased to 4, for example, the result would be:

  • $25
  • $25
  • $25
  • $25

When i hard code random numbers as the values for "Money" and "Time", the result is exactly what i need, just like the example above. But whenever i try to get the values from Session Storage, the result is always ONE topic of the <li> that i wanted to create, just like the example below:

Money: 100 / Days: 2

  • $50

My code so far:

<p id="money-value"></p>
<p id="time-value"></p>
<div id="payments"></div>
<script>
   const displayMoney = document.getElementById("money-value");
   const storedMoney = parseInt(sessionStorage.getItem("Money"));
   window.addEventListener("load", () => {
       displayMoney.innerHTML =  "Money: " + storedMoney
   });
   
   const displayTime = document.getElementById("time-value");
   const storedTime = parseInt(sessionStorage.getItem("Time"));
   window.addEventListener("load", () => {
       displayTime.innerHTML =  "Time: " + storedTime
   });
   
   var calc = storedMoney / storedTime;
   
   for (let i = 0; i < storedTime; i++) {
      var list = document.createElement("li");
      list.innerText = `${calc}`;
      document.getElementById("payments").appendChild(list);
   }
   
</script>

TL;DR

What i'm really struggling with, is to make the <li> display the payments in the same number of topics as the number of days.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda