button5.addEventListener('click', () => {
// Fill the table content
var tableBody="";
tableBody=document.getElementById('tablebody');
var queryString = 'SELECT * FROM clientes';
connection.query(queryString, function(err, results) {
if (err) throw err;
console.log(results);
//console.log('Post Titles: ', rows[3]);
for (i = 0; i < results.length; i++) {
tableBody += '<tr>';
tableBody += ' <td>' + results[i].idCliente + '</td>';
tableBody += ' <td>' + results[i].nombreCliente + '</td>';
tableBody += ' <td>' + results[i].apellidoCliente + '</td>';
tableBody += ' <td>' + results[i].cedulaCliente + '</td>';
tableBody += ' <td>' + results[i].telefonoCliente + '</td>';
tableBody += ' <td>' + results[i].celularCliente + '</td>';
tableBody += ' <td>' + results[i].direccionCliente + '</td>';
tableBody += ' <td>' + results[i].emailCliente + '</td>';
tableBody += '</tr>';
}
});
connection.end(() => {
//
});
//
});
entre Desarrolladores
Recibe ayuda de expertos
Registrate y pregunta
Es gratis y fácil
Recibe respuestas
Respuestas, votos y comentarios
Vota y selecciona respuestas
Recibe puntos, vota y da la solución
Pregunta
Tabla dinamica en Electron node js con mysql pero solo logro mostrar los resultados por console.
- preguntó
- Escritorio
- 4764 Vistas
- 1 Respuestas
- abierta
1 Respuesta
Saludos
HTML
Me imagino que así es más o menos la estructura de tu tabla.
<table>
<caption>Clientes</caption>
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Cédula</th>
<th>Teléfono</th>
<th>Celular</th>
<th>Dirección</th>
<th>Correo</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>
JS necesitas hacer un innerHTML para que lo inserte dentro del tbody
button5.addEventListener('click', () => {
// Fill the table content
var tableBody="";
var queryString = 'SELECT * FROM clientes';
connection.query(queryString, function(err, results) {
if (err) throw err;
console.log(results);
for (i = 0; i < results.length; i++) {
tableBody += '<tr>';
tableBody += ' <td>' + results[i].idCliente + '</td>';
tableBody += ' <td>' + results[i].nombreCliente + '</td>';
tableBody += ' <td>' + results[i].apellidoCliente + '</td>';
tableBody += ' <td>' + results[i].cedulaCliente + '</td>';
tableBody += ' <td>' + results[i].telefonoCliente + '</td>';
tableBody += ' <td>' + results[i].celularCliente + '</td>';
tableBody += ' <td>' + results[i].direccionCliente + '</td>';
tableBody += ' <td>' + results[i].emailCliente + '</td>';
tableBody += '</tr>';
}
document.getElementById("tablebody").innerHTML = tableBody;
});
connection.end(() => { });
});
Así debería de funcionar
Por favor, accede o regístrate para añadir un comentario.
Por favor, accede o regístrate para responder a esta pregunta.
En el blog
-
- 407147
- 1
- Jul 5, 2015
Sin Respuesta
-
- 169
- 0
- Mar 19
-
- 86
- 2
- Feb 26
-
- 1139
- 0
- Nov 7, 2023
-
- 302
- 0
- Sep 19, 2023
-
- 305
- 0
- Ago 21, 2023
-
- 388
- 0
- May 14, 2023
-
- 358
- 0
- Abr 21, 2023
-
- 445
- 0
- Mar 31, 2023
- ver todas
Actividad Reciente
ArtEze respondió hace 1 día
Alguien sabe, no me ignorenArtEze seleccionó una respuesta hace 1 día
Bajar extensión de Chrome sin actualizar el navega…ArtEze respondió hace 1 día
Bajar extensión de Chrome sin actualizar el navega…ArtEze preguntó hace 1 día
Bajar extensión de Chrome sin actualizar el navega…ArtEze respondió hace 1 día
No me deja instalar OracleArtEze respondió hace 1 día
Formulario que guarde los datos de un jsonArtEze comentó hace 1 día
Script /boot/ scrapingSantiago2610 comentó Mar 23
Acualizar ChoiceField en djangoSantiago2610 preguntó Mar 19
Acualizar ChoiceField en djangogonzalss preguntó Feb 26
Script /boot/ scraping
Ultimas Preguntas
Usuarios Top
- Leonardo-Tadei
- 227320 Puntos
- Peter
- 150470 Puntos
- white
- 75880 Puntos
- carlossevi
- 63580 Puntos
- magarzon
- 30650 Puntos
- pregunton
- 20400 Puntos
Todos los Usuarios Usuarios Nuevos
...