1
how to get value of this input inside the table with data from the bd:
HTML CODE
<table id="tbl_3" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style='text-align: center;' >NOME</th>
<th style='text-align: center;' >SETOR</th>
<th style='text-align: center;' >QTD</th>
<th style='text-align: center;' >R$</th>
<th style='text-align: center;' >QTD</th>
<th style='text-align: center;' >R$</th>
<th style='text-align: center;' >QTD</th>
<th style='text-align: center;' >R$</th>
<th style='text-align: center;' >QTD</th>
<th style='text-align: center;' >R$</th>
</tr>
</thead>
<tbody>
<?
foreach($z as $item){
?>
<tr>
<td style='text-align: left; width: 250px'><?=$item['nome']; ?></td>
<td style='text-align: center; width: 250px''><?=$item['setor']; ?></td>
<td style='text-align: center; width: 62px' class="editar1" > <?=$item['qtd1']; ?> <input type="text" id="qtd1" name="qtd1" value="<?=$item['id']; ?>" /> </td>
<td style='text-align: center; width: 62px'><?=$item['valor1']; ?></td>
<td style='text-align: center; width: 62px' ><?=$item['qtd2']; ?></td>
<td style='text-align: center; width: 62px'><?=$item['valor2']; ?></td>
<td style='text-align: center; width: 62px' ><?=$item['qtd3']; ?></td>
<td style='text-align: center; width: 62px'><?=$item['valor3']; ?></td>
<td style='text-align: center; width: 62px' ><?=$item['qtd4']; ?></td>
<td style='text-align: center; width: 62px'><?=$item['valor4']; ?></td>
</tr>
<? } ?>
JS CODE
$('#tbl_3 tbody tr td.editar1').dblclick(function(){
var idElemento = $('#tbl_3 tbody tr td input').val() ; console.log(idElemento);
I want to get the ID that is in this input to handle a BD update.
This taking the ID of the element, but only returns the one of the first line ... I need each line I receive the corresponding ID !!
– Thiago Lopez
Of course you’re only taking the first line, you’re just selecting the
td.editar1
in the click event.– Jorge.M
I use to make the event call, even taking only returns me the input value of the first line, the following lines should show their values
– Thiago Lopez
I edited the answer, now it captures the id as clicked. Take a look to see if it suits you.
– Jorge.M
right, but the ID I want is the input value, see that I get the ID value in php to update the corresponding data.
– Thiago Lopez
Because you asked your question badly, because you say you need to capture the id and not the value.
– Jorge.M
ta ... it was bad
– Thiago Lopez
I edited again... Look there.
– Jorge.M