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

202
Views
How to display localStorage value in a table header?

I have the following js function that is used to get the saved value of an input field:

function getSavedValue(e) {
    if (!localStorage.getItem(e)) {
        return "";
    }
    return localStorage.getItem(e);
}

The following is an example of how I use this js function:

var paymentMonth = document.getElementById("monthHR_PaymentMonth");

paymentMonth.value = getSavedValue("monthHR_PaymentMonth");

How can I use this function to grab the paymentMonth value and display it in a table column header?:

<th>Payment May 2022</th>

Where May 2022 is the value saved.

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

0

How can I use this function to grab the paymentMonth value and display it in a table column header?: You can try to add an id to the <th></th>:

<th id="monthHR_PaymentMonth"></th>

and then use the following code to add text to it:

$("#monthHR_PaymentMonth").append(getSavedValue("monthHR_PaymentMonth"));
about 4 years ago · Juan Pablo Isaza Report

0

You need the element to have an id attribute in order to get it with the getElementById function. So add an id to the <th>, then use the textContent property to add text to it:

var paymentMonth = document.getElementById("monthHR_PaymentMonth");

paymentMonth.textContent = getSavedValue("monthHR_PaymentMonth");
about 4 years ago · Juan Pablo Isaza Report

0

const paymentMonth = document.getElementById("monthHR_PaymentMonth");
paymentMonth.innerText = getSavedValue("monthHR_PaymentMonth");

use innerText!

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!