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

103
Views
Change Table Headers On URL Variable String

I have a website table that shows a variety of data, which currently changes which data are viewed based on a variable string passed in the URL. This example looks as follows:

www.acoolwebsite.com/?variable=var1

I've provided a synthesized view of the table's current header structure, which is as follows:

<html>
    <head>
    <style>
    table, th, td {
      border: 1px solid black;
    }
    </style>
    </head>
    <body>
    <table>
      <tr>
        <th>Static1</th>
        <th>Static2</th>
        <th>Static3</th>
        <th>Variable1</th>
        <th>Variable2</th>
        <th>Variable3</th>
      </tr>
    </table>
    </body>
    </html>

I am looking to change the headers Variable1, Variable2, & Variable3 to another set of headers, say Change1, Change2, & Change3 if the passed variable in the URL www.acoolwebsite.com/?variable=var1 matches a certain string.

Using JavaScript, I've been able to partition the variable passed in the URL, but am uncertain how to isolate and alter header names. What additional steps can I take to produce this outcome? Thanks!

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

0

You should assign an ID for your table headers and use innerHTML. See sample snippet below:

<html>
    <head>
    <style>
    table, th, td {
      border: 1px solid black;
    }
    </style>
    </head>
    <body>
    <table>
      <tr>
        <th>Static1</th>
        <th>Static2</th>
        <th>Static3</th>
        <th id="v1">Variable1</th>
        <th id="v2">Variable2</th>
        <th id="v3">Variable3</th>
      </tr>
    </table>
    
    <input type="button" value="Click" onclick="changeHeaders()" />
<script>
function changeHeaders() {
  // You variables
  let v1 = 'change1';
  let v2 = 'change2';
  let v3 = 'change3';
  document.getElementById("v1").innerHTML = v1;
  document.getElementById("v2").innerHTML = v2;
  document.getElementById("v3").innerHTML = v2;
}
</script>
    
    </body>
</html>

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!