Closed andrescallejas closed 8 years ago
Try using the textExtractor
option to look for an input or select and fallback to the cell text if nothing is found:
$('table').tableToJSON({
textExtractor : function(cellIndex, $cell) {
// get text from an input or select inside table cells;
// if empty or non-existent, get the cell text
return $cell.find('input, select').val() || $cell.text();
}
});
Thanks so solve it
$('#tablaServicio' + x).find('tbody tr').each(function (fila) {
var s = {hora: '', empleada: '', tiempo: '', valor: ''};
$(this).children('td').each(function (columna) {
switch (columna) {
case 0: //hora
s.hora = $(this).text();
break;
case 1: //empleada
s.empleada = $(this).find('select').val();
break;
case 2: //tiempo
s.tiempo = $(this).find('select').val();
break;
case 3: //tiempo
s.valor = $(this).find('input').val();
break;
}
});
obj.servicios.push(s);
});
$('#tablaProductos' + x).find('tbody tr').each(function (fila) {
var p = {hora: '', producto: '', cantidad: '', valor: '', total: ''};
$(this).children('td').each(function (columna) {
switch (columna) {
case 0: //hora
p.hora = $(this).text();
break;
case 1: //producto
p.producto = $(this).find('select').val();
break;
case 2: //cantidad
p.cantidad = $(this).find('input').val();
break;
case 3: //valor
p.valor = $(this).find('input').val();
break;
case 4: //total
p.total = $(this).find('input').val();
break;
}
});
obj.productos.push(p);
});
thanks....
I have a project of multiplex tables , which have select and input. I am using table- to- json and I take all the data and select the input data does not take me as I do to take further data I need to add an id to identify the property that is the information table .