I have an HTML table that dynamically filled with a table of a BD, to each row that returns I add an input text to add certain information for each row, one row has nothing to do with the others, now it has I have placed a different name for each input of the table, when I position myself in the input of a row, I should get an id that is painted in the table to validate that information with ajax, the problem I have is that I have the code to obtain that value but only by placing the id of the specific input and not in a general way for any input that I select, how can I do that JS function so that I can get that value for any input?
<script>
$(document).ready(function () {
//El id de los input comienza con numeroFac-0, numeroFac-1...
$('#numeroFac-0').on('focus', function () {
var hola = $(this).parent().parent();
hola.children().each(function () {
var celdas = hola.children();
$('#txtNombre').val($(celdas[0]).text());
$('#test').val($(celdas[1]).text());
$('#txtFechaa').val($(celdas[3]).text());
});
});
});
</script>
this is my table or the html
<table class="table table-striped table-condensed">
<thead>
<tr>
<th><i class="glyphicon glyphicon-asterisk"></i> Cliente</th>
<th><i class="glyphicon glyphicon-user"></i> Nombre</th>
<th style="text-align:center"><i class="glyphicon glyphicon-info-sign"></i> Total compras</th>
<th style="text-align:center"><i class="glyphicon glyphicon-info-sign"></i> Total a comisionar</th>
<th style="text-align:center"><i class="glyphicon glyphicon-info-sign"></i> Alcance %</th>
<th><i class="glyphicon glyphicon-info-sign"></i> Monto $</th>
<th><i class="glyphicon glyphicon-info-sign"></i> Concepto</th>
<th><i class="glyphicon glyphicon-info-sign"></i> Ingresar Factura</th>
</thead>
<tbody>
@Code If consultaComisiones.Count > 0 Then End Code
@Code For Each item1 In consultaComisiones End Code
<tr>
@Code If item1("Alcance") >= "80" And (item1("NIVEL_PRECIO") = "DAF B" Or item1("NIVEL_PRECIO") = "DAF C") Then End Code
<td>@item1("Cliente") <input type="text" id="numeroCliente" name="numeroCliente" value="@item1("Cliente")" /></td>
<td>@item1("Nombre") <input type="text" id="nombreCliente" name="nombreCliente" value="@item1("Nombre")" /></td>
<td style="text-align:center">@item1("total_compras") <input type="text" id="totalCompras" name="totalCompras" value="@item1("total_compras")" /> </td>
<td style="text-align:center">@item1("total_parad") <input type="text" id="totalComisionar" name="totalComisionar" value="@item1("total_parad")" /> </td>
<td style="text-align:center">@item1("Alcance") % <input type="text" id="alcance" name="alcance" value="@item1("Alcance")" /> </td>
<td>@Format(item1("Monto"),"C") <input type="text" id="monto" name="monto" value="@item1("Monto")" /> </td>
<td>Permanencia Amigo Chip 60 Dias(@item1("MES") @item1("ANIO"))@item1("total_parad") -lineas <input type="text" id="concepto" name="concepto" value="Permanencia Amigo Chip 60 Dias(@item1("MES") @item1("ANIO"))@item1("total_parad") -lineas" /> </td>
<td><input type="text" id="numeroFactura-@i" /></td>
@Code i = i + 1
End If End Code
</tr>
@Code Next End Code
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><center><button type="button" id="btnGuardar" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk"></span> Guardar</button></center></td>
</tr>
@Code Else End Code
<tr>
<td colspan="8" >
<span style="color:red"><i class="glyphicon glyphicon-remove"></i> No existen resultados con los parametros de búsqueda que elegiste... </span>
</td>
</tr>
@Code End If End Code
</tbody>
</table>
</form>
<span class="text-success">Registros encontrados.: <span class="badge">@i</span></span>
<div id="resultados" ></div>