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

74
Views
Función de búsqueda en PHP

Estoy tratando de insertar una función de búsqueda en mi sitio web, la que encontré puede encontrar datos de varias columnas (lo cual es genial), pero el problema es que después de que se muestran los resultados de la búsqueda, el encabezado de texto no se muestra (que es no es bueno). ¿Alguien sabe cómo mostrar los resultados de búsqueda, incluido el encabezado de texto? Todavía soy nuevo en la codificación, lo siento.

 <script> function tableSearch() { // Declare variables var input, filter, table, tr, td, i; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("T_SJSM"); tr = table.getElementsByTagName("tr"); // Loop through all table rows AND COLUMNS, and hide those who don't match the search query for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td"); var match = false; //Loop trough all columns for(var j = 0; j < td.length; j++) { if(td[j]) { txtValue = td.textContent || td.innerText; if (td[j].innerHTML.toUpperCase().indexOf(filter) > -1) { match = true; } } } //Match found in one or multiple columns if (match) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } </script>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Debe omitir la primera fila (que es la fila del encabezado)

Así que comienza tu ciclo desde 1

 for (i = 1; i < tr.length; i++) {
about 4 years ago · Juan Pablo Isaza Report

0

La estructura de tu tabla debería ser así.

 <table> <thead> <tr></tr> </thead> <tbody> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> </tbody> </table>

Si su tabla se ve así, puede cambiar solo una línea como esta:

 tr = document.querySelector('tbody').getElementsByTagName("tr");
about 4 years ago · Juan Pablo Isaza Report

0

tabla = documento.getElementById("T_SJSM");

agregue la identificación "T_SJSM" al tbody

o comience el primer bucle (bucle tr) desde 1.

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!