0
Well I have an editable table, where I only change the quantity, I already get the value of the first column and the last. I need to take the value of docEntry with java script but as I understand little of js I’m not getting, can someone give me this help? Thanks
<table id="tblEditavel" data-height="299" data-show-columns="true" class="table table-striped table-condensed">
<thead>
<tr>
<th>N</th>
<th>Numero do pedido</th>
<th>Descrição</th>
<th>Cod do item</th>
<th >Quantidade</th>
</tr>
</thead>
<tbody>
@for($i=0 ;$i < count($produtos);$i++)
<tr>
<td>{{$i }}</td>
<td title="DocEntry">{{ $produtos[$i]->DocEntry }}</td>
<td title="Dscription">{{ $produtos[$i]->Dscription}}</td>
<td title="ItemCode" >{{ $produtos[$i]->ItemCode}}</td>
<td title="quantidade" class="editavel">{{ $produtos[$i]->U_QTDCONF}}</td>
</tr>
@endfor
</tbody>
$(document).ready(function(){
$('#tblEditavel tbody tr td.editavel').dblclick(function(){
if ( $('td > input').length > 0){
return;
}
var conteudoOrigininal = $(this).text();
var novoElemento = $('<input/>', {type:'text', value:conteudoOrigininal});
$(this).html(novoElemento.bind('blur keydown', function(e){
var keyCode = e.which;
if( keyCode == 9 ){
var conteudoNovo = $(this).val();
var numero = $(this).parents('tr').children().first().text();
var campo = $(this).parent().attr('title');
if( conteudoNovo != "" ){
$(this).parent().html(conteudoNovo);
}
$.ajax({
type:"POST",
url:'../produto/cadastrar-quantidade',
data:{
id:numero,
campo:campo,
valor:conteudoNovo,
_token: $('input[name="_token"]').val()
},
success:function(result){
$(this).parent().html(conteudoNovo);
$('body').append(result);
}
})
}
if(e.type == "blur") {
$(this).parent().html(conteudoOrigininal);
}
}));
$(this).children().select();
})
})
don’t understand well, you want to always take the value of Docentry? can’t add a class and use
$(".DocEntry").html()
for example, or is it something even more?– h3nr1ke
I made it easier.. the value of docEntry is unique in this case, I passed the value as variable to view and took js thanks for the help.
– Raphael Barauna