My problem is this, I'm trying to insert some values into a database (dynamic) html with editable fields, I already have the function that inserts, but my problem is how to relate the value that I place in the table with what I want through a jquery.
This is how I build my table:
if (isset($dataRubroTerm)) {
// el script declarado en esta parte del controlador justo antes de la tabla hace que funcionen los eventos jquery
$html = "
<script>
$('.prueba').on('focusin','tr',function(){
$( '.prueba td ' ).focusout(function( event ) {
var precio= $(this).text();
console.log(+precio);return false;
});
});
</script>
<table class='table table-striped table-bordered table-hover prueba'>
<tr>
<td> <b>Rubro seleccionado - " . $dataRubro->descripcion /*aca cambia dependiendo de el rubro que se seleccione*/. "</b> </td>
<td> <b>PRECIO MAR</b> </td>
<td> <b>PRECIO ANA</b> </td>
<td> <b>PRECIO DE CAJA</b> </td>
<td> <b>PRECIO EXT</b> </td>
<td> <b>MARCAS</b> </td>
</tr> ";
foreach ($dataRubroTerm AS $fila[0]) { // aca se autogenera la tabla.
$PrecioMar = Monitoreo::buscarPrecios($idMonitor, 1, $fila[0]->id_rub_term); //Esto hace la busqueda por bdd a ver si hay precios guardados previamente , al igual con la marca.
$PrecioAna = Monitoreo::buscarPrecios($idMonitor, 2, $fila[0]->id_rub_term);
$PrecioDCaja = Monitoreo::buscarPrecios($idMonitor, 3, $fila[0]->id_rub_term);
$PrecioExt = Monitoreo::buscarPrecios($idMonitor, 4, $fila[0]->id_rub_term);
$marcas = Monitoreo::buscarPrecios($idMonitor, 5, $fila[0]->id_rub_term);
$html .= "<tr>
<td> " . $fila[0]->fkPresentacion->descripcion . " </td>";
$html .= "<td class='numeric prueba' contenteditable='true'> " . ($PrecioMar == "" ? '0.00' : $PrecioMar) /*se coloca un condicional if (?) para usar la busqueda por base de datos y ver si hay o no hay algo guardado previamente*/ . "</td>";
$html .= "<td class='numeric prueba' contenteditable='true'>" . ($PrecioAna == "" ? '0.00' : $PrecioAna) . " </td>";
$html .= "<td class='numeric prueba' contenteditable='true'>" . ($PrecioDCaja == "" ? '0.00' : $PrecioDCaja) . "</td>";
$html .= "<td class='numeric prueba' contenteditable='true'>" . ($PrecioExt == "" ? '0.00' : $PrecioExt) . "</td>";
$html .="<td>" . ($marcas == "" ? 'Sin marca' : $marcas) . "</td></tr>";
}
}