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

105
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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