0
Hello, I am doing a college job, an academic control, and when trying to remove a tuple from the database by passing the "id" of the tuple via post form, the value arrives either empty or Undefined. Follows the code:
<tbody>
<%for(var i=0; i<lista.length; i++){%>
<tr>
<td class="mdl-data-table__cell--non-numeric"><%=lista[i].matricula%></td>
<td><%=lista[i].nome%></td>
<td><%=lista[i].IRA%></td>
<td><%=lista[i].codCurso%></td>
<td><%=lista[i].endereco%></td>
<td><button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" src"admin/alteraAluno" href="admin/formAluno">Editar</button></td>
<td>
<form action="removeAluno" method="POST">
<input type="hidden" name"matricula" value="<%= lista[i]%>"/>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">Remover</button>
</form>
</td>
</tr>
<%}%>
</tr>
</tbody>
Up here you have a table and two buttons, one to change, not yet implemented, and one to remove that when arriving at javascript comes empty or Undefined
var removeAlunoUniversidade = function(req, res){
var connection = app.infra.connectionFactory();
var adminDAO = new app.infra.AdminDAO(connection);
var lista = res.body;
console.log(lista);
adminDAO.removeAlunoUniversidade(lista, function(err, result){
res.redirect('listaAlunos');
});
connection.end();
};
app.post('/admin/removeAluno', removeAlunoUniversidade);
I wonder what I’m missing and if there’s any other way to do it.
I don’t know if your code is identical, but your input is missing with error, it is
name"matricula"
.... change toname="matricula"
– picossi
Thanks, it worked, detail went unnoticed! agr it n ta removing from the database, it follows function: Admindao.prototype.removeListenUniversity = Function(matricula, callback){ console.log(matricula); this. _Connection.query('DELETE FROM student WHERE
aluno
.matricula
set ? ', license plate, callback); }– Sérgio Neto
All settled!
– Sérgio Neto