So I'm trying to get the value of the USUARIO column when I'm pressing the button of its same row: For example, if I was about to press the first button, it should give me 3 as a result
In my code I have this:
function(response) {
var t = "";
var tr = "";
tr += "<thead>";
tr += "<th>USUARIO</th>";
tr += "<th>FECHA INICIO</th>";
tr += "<th>FECHA FIN</th>";
tr += "<th>TIPO EMERGENCIA</th>";
tr += "<th>LOCALIZACIÓN</th>";
tr += "<th>DESACTIVADOR</th>";
tr += "</thead>";
tr += '<tbody id="tbody' + i +">';
tr += '<td class= "OIDCELL">' + response[i].usuario_oid + "</td>";
tr += "<td>" + response[i].fechainicio + "</td>";
tr += "<td>" + response[i].fechafin + "</td>";
tr += "<td>" + response[i].tipoemergencia_tipo
+ "</td>";
tr += "<td>" + enlace + "</td>";
if (response[i].desactivador == 0){
tr += '<td> <button type="button" onclick="cambiarDesactivador()">Desactivar</button></td>';
}else{
tr += "<td>" + response[i].desactivador + "</td>";
}
tr += "</tr>";
tr += "</tbody>";
}
t += tr;
document.getElementById("historicoUser").innerHTML += t;
}
So in which way am I able to get the value of the USUARIO column of the same row of the pressed button?
Thank you in advance!
You could directly pass in the value response[i].usuario_oid
which you are showing in the column to your button's onClick function
example: cambiarDesactivador(response[i].usuario_oid)