Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda