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

145
Vistas
Generate new table when searching

I am trying to generate a table from an array with a searching feature. With every letter typed in the search bar the items that contain that specific string will be displayed.

I have come to the conclusion to generate the whole table with every keystroke rather than editing the current.

This is where I am at:

What´s currently typed in the searchbar:

  let searchBar = document.getElementById('search-input');

    let value = " ";
    searchBar.addEventListener(`keyup`, function(){
        value = this.value

How I make the table:

let tableUsers = document.getElementById("tabell");

function drawTable() {
    let table = document.createElement("table");
    let tableHead = document.createElement("thead");
    let colHeads = ["Name"];

    for (let header of colHeads) {
        let cell = document.createElement("th")
        cell.innerHTML = header;
        tableHead.appendChild(cell);
    }
    table.appendChild(tableHead)

    for (let x of people) {

        let row = document.createElement("tr");

        let name = document.createElement("td");
        name.innerHTML = x.name.first + "&nbsp" + x.name.last;
        row.appendChild(name);

        table.appendChild(row);
    }

    tableUsers.appendChild(table);
}
drawTable()

I am trying this:

let str = x.name.first.toLowerCase()

        if (str.includes(value)){
        //code
        }

Is it possible to do it this way? Or possible at all using JS and large arrays without using a lot of pc resources? Any help is greatly appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Inside if statement, you need to create new array then push the values inside it then you can pass a new people as a parameter to drawTable function and call it like drawTable(people)

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