-2
This button has an ONCLICK event that calls a function. Theoretically, it is already in a line, it would only need the VALUE of a cell.
Obs: Addresses is the ID of tbody and the TEST is the CELULA ID. Current function:
function teste(){
var id = $(this).parent().find('td').attr('id');
alert(**enderecos**[1].**teste**);
}
Function to recover data on screen:
function atualiza(){
$.ajax({
dataType: 'json',
url: 'get_enderecos.php',
success: function(data){
for(var i=0; data.length>i;i++){
$('#enderecos').append('<tr><td id="teste">'+data[i].sequencia+'</td>'+
'<td>'+data[i].cep+'</td>'+
'<td>'+data[i].endereco+'</td>'+
'<td>'+data[i].bairro+'</td>'+
'<td>'+data[i].cidade+'</td>'+
'<td>'+data[i].estado+'</td>'+
'<td class="actions col-xs-2 col-sm-2 col-md-2 col-lg-2" align="center">'+
'<button class="btn btn-danger" onClick="teste()" type="button">Alterar Endereço</button>'+
'</td></tr>');
}
}
});
}
TESTE
is theid
of the cell you want to search for ? But remember that you cannot have repeated id’s on a page– Isac
What value you are sending to the function
teste()
? If you don’t send anything, it’s impossible to do what you want.– Sam
Put the part of the code where you print this data on the screen. (It should be a while or json, whatever it is)
– Milrak Pereira Pessoa
in the test function, if I give an Alert(.cep addresses) it returns to me an indefined.
– leonardo barussi
Yes, testing is the cell ID I want to get
– leonardo barussi
<tr><td id="teste">
-> this creates several lines with the sameid
which is incorrect at html level See here in the W3C documentation how ids have to be unique– Isac