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

149
Views
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
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!