How i get all data in the table help
How i get all data in the table help
alderhernandez
Posts: 33Questions: 11Answers: 1
Hello, I'm trying to get all the data in a table,
but so monent I have not been able
for example i have this table
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
</tbody>
i need get all data foreach row
1 row ->{Tiger Nixon,System Architect,Edinburgh,61,2011/04/25,$320,800}
2 row->{Garrett Winters,Accountant....................etc etc}
I'm testing with this code
$("#tblCatalogoActualModal td").each(function(index) {
$(this).parents("tr").find("td").each(function(){/*metodo para recorrer la tabla*/
alert($(this).html());
switch($(this).parent().children().index($(this))) {//obtengo el index de la columna EKISDE
case 0:
codigo = $(this).html();
break;
case 1:
articulo = $(this).html();
break;
case 2:
break;
case 3:
puntos = $(this).html();
break;
case 5:
break;
default:
//alert($(this).html());
}
});
alert("out");
/*var form_data = {
codigo: codigo,
puntos: puntos,
articulo: articulo,
IdCatalogo: IdCatalogo
};
$.ajax({
url: "actualizarCatalogo",
type: "post",
async:true,
data: form_data,
success:
function(json){
Materialize.toast('SE GUARDARON LOS CAMBIOS EN EL CATALOGO, ESPERE..', 3000);
var myVar = setInterval(myTimer, 2000);
}
});*/
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
So... when you initialize the datatable do something like:
and now you ajax you form_data;
@DirceuNazareth thanks men!!!!
I guess the form_data is an array and I need to cross it to get value for value.?
for example
ist that ok?
That depends how you initialized that data. It can be a 2d array, or array of objects:
But, yes will be an array.
hi @DirceuNazareth thanks for the help, her is mi initialization, i am draw the table with php
the data was create with php "echo" ....
how I can get each of the array elements?
for example
plis.. tthanks for the help
If that is the case, you have 2d array:
taking your initial post HTML as example:
To iterate over it:
BTW... do you speak spanish or portuguese?
@DirceuNazareth thanks men, you know why only works in the first row? in the others show me "undefined". i speak spanish... sorry my bad english
Oops my fault
thanks @DirceuNazareth .. lately but works. thanks man