<html>
<head>
<title>sum of all textbox each row</title>
<script src ="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<input type="number" class="txtnum" id="txt1"><br/>
<input type="number" class="txtnum" id="txt2"><br/>
<input type="text" id="total" disabled />
</body>
<script>
$(document).ready(function(){
<title>sum of all textbox each row</title>
<script src ="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<input type="number" class="txtnum" id="txt1"><br/>
<input type="number" class="txtnum" id="txt2"><br/>
<input type="text" id="total" disabled />
</body>
<script>
$(document).ready(function(){
$(".txtnum").each(function(){
$(this).keyup(function(){
$(this).keyup(function(){
//var rowid = parseInt($(this).attr('id').split('_').pop());
var total = 0;
$(".txtnum").each(function(){
if (!isNaN(this.value) && this.value.length != 0){
total += parseFloat(this.value);
}
});
$('#total').val(total.toFixed(2));
});
});
});
</script>
</html>
var total = 0;
$(".txtnum").each(function(){
if (!isNaN(this.value) && this.value.length != 0){
total += parseFloat(this.value);
}
});
$('#total').val(total.toFixed(2));
});
});
});
</script>
</html>
0 Comments
if you have any doubts , please let me know