php - How to compare textbox value with table cell value -
i have table displays values of product name , available stock retrieving database. want insert quantity manually.
the code contains php incremental id's table row, available stock cell , quantity textbox, such last_<?php echo $id; ?>
stock , quanti_<?php echo $id; ?>
quantity.
i want compare these 2 values such quantity value must less or equal stock value.onclick
of generate bill button again want validate not submit form if quantity greater stock.
$(".edit_td1").click(function() { var id=$(this).attr('id'); //alert(id); //$('#quanti_'+id).blur(function(){ $('.cls_quant').blur(function(){ //var id=$(this).attr('id'); //var qt=$('#quanti_'+id).val(); var qt=$(this).val(); var stk=$('#last_'+id).html(); console.log("quanty"+qt); console.log("stock"+stk); if (qt>stk) { console.log("quantity > stock"); return false; } else return true; }); });
i suggest add parseint() fucntion vars that:
var qt = parseint($(this).val()); var stk= parseint($('#last_'+id).html());
i hope helps
Comments
Post a Comment