1
I have a little problem. I have a table with stock values, and I need to change these values as follows. The customer will insert a quantity that he wishes to manufacture of a certain product, and in the system need to inform the quantity that will be used of each raw material. But what’s wrong with me? the JS created is returning the value of the first line *(times) the amount reported, for each line, when the value of each line should be *(times) the amount reported. Follow the script if someone has a LIGHT =D
$('#calcular').click(function(){
var qtd = $('#qtd').val();
$.ajax({
beforeSend: function(){
waitingDialog.show('Calculando',{dialogSize: 'sm'});
},
success: function(){
waitingDialog.hide();
$('.comp_qtd').html(parseInt($('.comp_qtd').html())*parseInt(qtd));
}
})
});
Follow the button created to "Calculate":
<div class="col-sm-2">
<?= $this->Form->input('qtd',[
'label' => 'Quantidade',
'type' => 'text',
'placeholder' => 'Digite a qtd',
'id' => 'qtd',
'name' => 'qtd',
'class' => 'form-control',
'title' => 'Digite a quantidade a ser produzido na OS',
'required' => true
]);
?>
</div>
<div class="col-sm-2">
<button id="calcular" class="btn btn-primary pula" type="button">Calcular <i class="glyphicon glyphicon-sort"></i></button>
</div>
and the table to be amended:
<thead>
<tr>
<th>Codigo</th>
<th>Produto</th>
<th>Unidade</th>
<th>Quantidade Necessaria</th>
<th>Quantidade em Estoque</th>
</tr>
</thead>
<tbody>
<?php foreach($arrayComposicao as $composicao) :?>
<tr>
<td id="comp_codigo"><?= $composicao['Produto']['pro_codigo_id']?></td>
<td id="comp_descricao"><?= $composicao['Produto']['pro_descricao']?></td>
<td id="comp_medida"><?= $composicao['Composicao']['comp_mp_medida']?></td>
<td class="comp_qtd"><?= $composicao['Composicao']['comp_mp_qtd']?></td>
<td id="comp_estoque"><?= $composicao['Produto']['pro_qtd_estoque']?></td>
</tr>
<?php endforeach; ?>
</tbody>
I understood the idea, but how would you do for each <td> search a dynamic id by Row?
– Alex Agnar
Conssegui generate dynamic ID, now I will search on how to make JS take this generated id and make the change according to the generated id
– Alex Agnar