Greetings community how are you doing? this time I come with a concern about arrays, it turns out that I'm creating an array from an event in a specific cell of a Datatable, I need to click on an ID field that I have in the datatable, all the data in that row can be converted into an array.
I show you the code that is responsible for obtaining the values of the selected row:
$("td.clic").click(function(){
var valores="";
var identy="";
var $objeto=[];
// Obtenemos todos los valores contenidos en los <td> de la fila
// seleccionada
$(this).parents("tr").find("td").each(function(){
identy=$(this).attr("id");
valores=$(this).text();
$objeto.push({index:identy,value:valores});
});
});
Well ... there the code initially fulfills its purpose, that is, I get the value of both the ID of the TD of the table and the value of each of the cells.
The problem arises when I want to make the array object, I want to get an array with a key-value structure where the key is an object.
However, the way I'm doing it, I get an array like this:
Object { index: "id", value: "2" }
Object { index: "tipoequipo", value: "MAQUINA DE RAYOS X" }
Object { index: "marca", value: "PRUEBA" }
Object { index: "serial", value: "1234578QWERTY" }
Object { index: "bien", value: "4475121" }
I would like it to be like this:
id:"2"
tipoequipo:"MAQUINA DE RAYOS X"
marca: "PRUEBA"
serial: "1234578QWERTY"
bien: "4475121"
How can I achieve it? Thank you in advance.