Good day, I have a problem when trying to program the KeyCode event. I'm sure it has nothing to do with the JQuery library because I already tested an alert, which tells me it's working fine.
I hope you can help me, I have reviewed the code several times but I have not been able to see the error.
I leave the fragment of the code where the input is and the part of js where the event is located.
Thanks in advance
<tbody>
<tr>
<td data-th="Product">
<div class="row">
<form id="bestellung" class="kauft" action="" method="post">
<div class="col-sm-2 hidden-xs"><img src="<?php echo $daten[$i]['foto'];?>" alt="..." class="img-responsive"/></div>
<div class="col-sm-10">
<h4 class="nomargin"><?php echo $daten[$i]['name']; ?></h4>
<p><h4><b><em>Details:</em></b></h4></p>
<p><b>Produkt Typ:</b> <?php echo $daten[$i]['ptyp']; ?></p>
<p><b>Herkunfsland:</b> #########</p>
<p>T<b>ransportwege:</b>#########</p>
<p><b>Containertyp:</b>#######</p>
</div>
</div>
</td>
<td data-th="Price"><?php echo "€" . number_format( $daten[$i]['preis'],2); ?></td>
<td data-th="Price"><?php echo "€" . number_format( $daten[$i]['preis'],2); ?></td>
<td data-th="Price"><?php echo "€" . number_format( $daten[$i]['preis'],2); ?></td>
<td data-th="Quantity">
<input type="text" class="form-control text-center" value="<?php echo $daten[$i]['menge'];?>"
data-preis="<?php echo "€" . number_format( $daten[$i]['preis'],2); ?>"
data-id="<?php echo $daten[$i]['produkt_id']; ?>"
class="menge">
</td>
<td data-th="Subtotal" class="text-center"><?php echo $daten[$i]['menge']* $daten[$i]['preis'];?></strong></td>
<td class="actions" data-th="">
<button class="btn btn-info btn-sm"><i class="fa fa-refresh"></i></button>
<button class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i></button>
</td>
</tr>
</tbody>
<tfoot>
<tr class="visible-xs">
<td class="subtotal"><strong><?php echo $daten[$i]['menge']* $daten[$i]['preis'];?></strong></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td colspan="2" class="hidden-xs"></td>
<td class="hidden-xs text-center">
<strong>Total <?php echo ($daten[$i]['menge']*$daten[$i]['preis'])+$summe;?>
</strong></td>
<td></td>
</tr>
</tfoot>
</table>
</form>
</div>
<?php $summe=($daten[$i]['menge']*$daten[$i]['preis'])+$summe;
}
}else {
echo "<center><h2>El carro de compras esta vacio</h2></center>";
}
echo '<center><h2 id="summe"> Summe: '.$summe.'</h2></center>';
if($summe!=0){
}
Jquery Code
var inicio=function () {
$(".menge").keyup(function(e){
if($(this).val()!=''){
if(e.keyCode==32){
var id=$(this).attr('data-id');
var preis=$(this).attr('data-preis');
var menge=$(this).val();
$(this).parentsUntil('.Produkt').find('.subtotal').text('Subtotal: '+(preis*menge));
$.post('./js/modificarDatos.php',{
Id:id,
Preis:preis,
Menge:menge
},function(e){
$("#summe").text('summe: '+e);
});
}
}
});
}
$(document).on('ready',inicio);