I am developing a shopping cart using codeigniter. In my cart page I need to update my cart on change in quantity of the item. I am getting the results with the help of button click. But my issue is that I need to get the same result on my key up. For that on key up corresponding button should be clicked
View page
<td>
<?php echo form_input(array('name' => $items['rowid']."_qty",'id' => $items['rowid']."_qty", 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?>
<button class="btn btn-success " id= "<?php echo $items['rowid']."_qty" ?>" onclick="update_cart('<?=$items['rowid'];?>')" >update</button>
<script>
$("#<?php echo $items['rowid']."_qty" ?>").keyup(function(event){
$("#<?php echo $items['rowid']."_qty" ?>").click();
});
</script>
</td>
Script for update cart
function update_cart(itemid)
{
var qty= document.getElementById(itemid+"_qty").value;
$.ajax({
type: 'POST',
url: '<?php echo site_url("ajax_controller1/update_cart/'+itemid+'/'+qty+'")?>',
data: { id:itemid },
success:function(response){
$("#shoppingcart_container").html(response);
$(".total").click();
}
});
}
I just need to click currosponding button on change in quantity input field This is my Demo URL My website link