Javascript to calculate input figures from form input - javascript
I am trying to create a javascript that calculates the sum of 4 amounts, that is generated from the input fields.
The problem is, I want the Total Invoice Value to start reflecting the value after the user has inputted the Rate 1 and Amount 1 has shown. But it doesnt happen until all the 4 amounts have been generated. The Total Invoice Value reflect only after I input the amount in Rate 4.
The complete code I am working with right now is:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form name="register" id="myForm" enctype="multipart/form-data" action="register" method="POST">
Qty 1:<input type="number" step="any" name="Qty1" autocomplete="off" id="Qty1" required><br>
Rate 1:<input type="number" step="any" name="Rate1" autocomplete="off" id="Rate1" class="rate" required><br>
Amount 1:<input readonly type="number" step="any" name="Amt1" autocomplete="off" id="Amt1" required><br><br>
Qty 2:<input type="number" step="any" name="Qty2" autocomplete="off" id="Qty2" required><br>
Rate 2:<input type="number" step="any" name="Rate2" autocomplete="off" id="Rate2" class="rate" required><br>
Amount 2:<input readonly type="number" step="any" name="Amt2" autocomplete="off" id="Amt2" required><br><br>
Qty 3:<input type="number" step="any" name="Qty3" autocomplete="off" id="Qty3" required><br>
Rate 3:<input type="number" step="any" name="Rate3" autocomplete="off" id="Rate3" class="rate" required><br>
Amount 3:<input readonly type="number" step="any" name="Amt3" autocomplete="off" id="Amt3" required><br><br>
Qty 4:<input type="number" step="any" name="Qty4" autocomplete="off" id="Qty4" required><br>
Rate 4:<input type="number" step="any" name="Rate4" autocomplete="off" id="Rate4" required><br>
Amount 4:<input readonly type="number" step="any" name="Amt4" autocomplete="off" id="Amt4" required><br><br>
Total Invoice Value:<input readonly type="number" step="any" name="TotalInvoiceValue" id="TotalInvoiceValue" pattern=".{1,}" autocomplete="off" required><br>
</form>
<script>
$('#Rate1').keyup(function(){
var Qty1;
var Rate1;
textone = parseFloat($('#Qty1').val());
texttwo = parseFloat($('#Rate1').val());
var result = textone * texttwo;
$('#Amt1').val(result.toFixed(2));
});
$('#Rate2').keyup(function(){
var Qty2;
var Rate2;
textone = parseFloat($('#Qty2').val());
texttwo = parseFloat($('#Rate2').val());
var result = textone * texttwo;
$('#Amt2').val(result.toFixed(2));
});
$('#Rate3').keyup(function(){
var Qty3;
var Rate3;
textone = parseFloat($('#Qty3').val());
texttwo = parseFloat($('#Rate3').val());
var result = textone * texttwo;
$('#Amt3').val(result.toFixed(2));
});
$('#Rate4').keyup(function(){
var Qty4;
var Rate4;
textone = parseFloat($('#Qty4').val());
texttwo = parseFloat($('#Rate4').val());
var result = textone * texttwo;
$('#Amt4').val(result.toFixed(2));
});
$('#Rate4').keyup(function(){
var Amt1;
var Amt2;
var Amt3;
var Amt4;
textone = parseFloat($('#Amt1').val());
texttwo = parseFloat($('#Amt2').val());
textthree = parseFloat($('#Amt3').val());
textfour = parseFloat($('#Amt4').val());
var result = textone + texttwo + textthree + textfour;
$('#TotalInvoiceValue').val(result.toFixed(2));
});
</script>
I tried to get the javascript to start taking totals from rate 1 itself by adding multiple element name in the #TotalInvoiceValue function like this:
$('#Rate1, #Rate2, #Rate3, #Rate4').keyup(function(){
var Amt1;
var Amt2;
var Amt3;
var Amt4;
textone = parseFloat($('#Amt1').val());
texttwo = parseFloat($('#Amt2').val());
textthree = parseFloat($('#Amt3').val());
textfour = parseFloat($('#Amt4').val());
var result = textone + texttwo + textthree + textfour;
$('#TotalInvoiceValue').val(result.toFixed(2));
});
But it still doesn't work.
I also tried assiging same class to all the Rate inputs like this:
html
<input id="Rate1" class="rate" type="text">
<input id="Rate2" class="rate" type="text">
<input id="Rate3" class="rate" type="text">
<input id="Rate4" class="rate" type="text">
javascript
$('.rate').on('keyup', function() {
let result = 0;
$('.rate').each(function() { result += parseFloat(this.value); });
$('#TotalInvoiceValue').val(result.toFixed(2));
})
And even this is not working for me. Please help.
In the Demo the following was used:
HTMLFormControlsCollection API
<input type="number">
<output></output>
oninput On-event Property
Event Delegation
Note: This is pure JavaScript.
If each input and output element has an initial value:
<input id="N0" type="number" value="0">
...
<input id="N*" type="number" value="0">
<output id="T0">0</output>
Then expressions like this will always be displayed as a number which is important if your event handler listens on an event that has an immediate reaction (ex. input, keypress, etc):
T0.value = N0.valueAsNumber + N1.valueAsNumber + ...N(N).valueAsNumber
Even though the only input the user uses was N0 at the time, N1 thu N(N) is still included in expression because they started off with value="0".
Demo
var sum = document.forms.sum;
var f = sum.elements;
var n0 = f.N0;
var n1 = f.N1;
var n2 = f.N2;
var n3 = f.N3;
var t0 = f.T0;
sum.oninput = add;
function add(e) {
if (e.target.className === "N") {
t0.value = n0.valueAsNumber + n1.valueAsNumber + n2.valueAsNumber + n3.valueAsNumber;
} else {
return false;
}
return false;
}
input {
font: inherit;
display: block;
width: 6ch
}
<form id='sum'>
<input id='N0' type='number' class='N' value='0'>
<input id='N1' type='number' class='N' value='0'>
<input id='N2' type='number' class='N' value='0'>
<input id='N3' type='number' class='N' value='0'>
<output id='T0'>0</output>
</form>
JSFiddle Example
https://jsfiddle.net/o2gxgz9r/47359/
HTML
<div>
Value 1: <input class="val" id="val1">
<br/>
Value 2: <input class="val" id="val2">
<br/>
Value 3: <input class="val" id="val3">
<br/>
Value 4: <input class="val" id="val4">
<br/>
Result: <input class="result">
</div>
JS
$(document).ready(function() {
var handleChange = function() {
var result = 0;
var setResult = true;
$(".val").each(function(){
if($(this).val() > 0) {
result += parseInt($(this).val());
} else {
setResult = false;
}
})
$(".result").val(setResult ? result : '');
};
$(".val").change(handleChange);
});
Thanks for all of your answers. Using your suggestions, this is how my problem got fixed:
HTML:
<form name="register" id="myForm" enctype="multipart/form-data" action="register" method="POST">
Qty :<input type="number" step="any" name="Qty1" autocomplete="off" id="Qty1" required><br>
Rate:<input type="number" step="any" name="Rate1" autocomplete="off" id="Rate1" class="rate" required><br>
Amount :<input readonly type="number" step="any" name="Amt1" autocomplete="off" id="Amt1" class="amt" required><br><br>
Qty :<input type="number" step="any" name="Qty2" autocomplete="off" id="Qty2" required><br>
Rate:<input type="number" step="any" name="Rate2" autocomplete="off" id="Rate2" class="rate" required><br>
Amount :<input readonly type="number" step="any" name="Amt2" autocomplete="off" id="Amt2" class="amt" required><br><br>
Qty :<input type="number" step="any" name="Qty3" autocomplete="off" id="Qty3" required><br>
Rate:<input type="number" step="any" name="Rate3" autocomplete="off" id="Rate3" class="rate" required><br>
Amount :<input readonly type="number" step="any" name="Amt3" autocomplete="off" id="Amt3" class="amt" required><br><br>
Qty :<input type="number" step="any" name="Qty4" autocomplete="off" id="Qty4" required><br>
Rate:<input type="number" step="any" name="Rate4" autocomplete="off" id="Rate4" class="rate" required><br>
Amount :<input readonly type="number" step="any" name="Amt4" autocomplete="off" id="Amt4" class="amt" required><br><br>
JAVASCRIPT:
$('#Rate1').keyup(function(){
var Qty1;
var Rate1;
textone = parseFloat($('#Qty1').val());
texttwo = parseFloat($('#Rate1').val());
var result = textone * texttwo;
$('#Amt1').val(result.toFixed(2));
});
$('#Rate2').keyup(function(){
var Qty2;
var Rate2;
textone = parseFloat($('#Qty2').val());
texttwo = parseFloat($('#Rate2').val());
var result = textone * texttwo;
$('#Amt2').val(result.toFixed(2));
});
$('#Rate3').keyup(function(){
var Qty3;
var Rate3;
textone = parseFloat($('#Qty3').val());
texttwo = parseFloat($('#Rate3').val());
var result = textone * texttwo;
$('#Amt3').val(result.toFixed(2));
});
$('#Rate4').keyup(function(){
var Qty4;
var Rate4;
textone = parseFloat($('#Qty4').val());
texttwo = parseFloat($('#Rate4').val());
var result = textone * texttwo;
$('#Amt4').val(result.toFixed(2));
});
$('.rate').on('keyup', function() {
var result = 0;
var setResult = true;
$('.amt').each(function() {
if($(this).val() > 0) {
result += parseFloat(this.value);
}
});
$('#TotalInvoiceValue').val(result.toFixed(2));
});
Related
javascript multiply 2 number show total and gtotal but show only one value?
I am using javascript calculation. multiply 2 numbers: number 1 * number 2 = total and how g-total but working only one value display? I have need number 1 * number 2 = total and show Gtotal so please help and share a valuable idea... HTML <input name="per_hour" id="per_hour" class="form-control" value="" onblur="perhour()" placeholder="0" /> <input name="per_hour_x" id="per_hour_x" class="form-control" onblur="perhour()" value="" placeholder="0.00" /> Total <input name="per_hour_total" id="per_hour_total" class="form-control" value="" placeholder="0.00" /> G-Total <input type="text" class="form-control total-fare" id="total" disabled value="<?= $booking->total_fare ?>" /> <script> function perhour() { var per_hour = document.getElementById("per_hour").value; var per_hour_x = document.getElementById("per_hour_x").value; var amts = document.getElementById("total").value; var totaperhour = Number(per_hour) * Number(per_hour_x); var totalamt = Number(totaperhour) + Number(amts); $("#per_hour_total").val(totaperhour).toFixed(2); //working $("#total").val(totalamt).toFixed(2); //not working } </script>
It should be $('#per_hour_total').val(totaperhour.toFixed(2)); and not $('#per_hour_total').val(totaperhour).toFixed(2); function perhour() { var per_hour = document.getElementById("per_hour").value; var per_hour_x = document.getElementById("per_hour_x").value; var amts = document.getElementById("total").value; var totaperhour = Number(per_hour) * Number(per_hour_x); var totalamt = Number(totaperhour) + Number(amts); $('#per_hour_total').val(totaperhour.toFixed(2)); $('#total').val(totalamt.toFixed(2)); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <div> total <input type="text" class="form-control total-fare" disabled id="total" value=""> </div> <div> per_hour <input name="per_hour" id="per_hour" class="form-control" value="" onblur="perhour()" placeholder="0"> </div> <div> per_hour_x <input name="per_hour_x" id="per_hour_x" class="form-control" onblur="perhour()" value="" placeholder="0.00"> </div> <div> per_hour_total <input name="per_hour_total" id="per_hour_total" class="form-control" value="" placeholder="0.00"> </div>
Calculation use key up function with a thousand separator format
i want to make a calculation when user key in, the result will show in other field. with format number with thousand separator like 2,500.00 so if i sum 2,500.00 + 2,500.00 the result must be 5,000.00 but my code show 4.00 function isNumberKey(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode(key); if (key.length == 0) return; var regex = /^[0-9.,\b]+$/; if (!regex.test(key)) { theEvent.returnValue = false; if (theEvent.preventDefault) theEvent.preventDefault(); } } function toFloat(z) { var x = document.getElementById(z); x.value = parseFloat(x.value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); } $( ".fn" ).keyup(function() { var nmi = $('#nmi').val(); var a = $('#a').val(); var total = parseFloat(nmi) + parseFloat(a); $("#total").val(parseFloat(total).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input onchange="toFloat('nmi')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="nmi" id="nmi"> <input onchange="toFloat('a')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="a" id="a"> <br> total <input onchange="toFloat('total')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="total" id="total">
Lets try this one,,, thats works for me "Dial Gtg" $('input.CurrencyInput').on('blur', function() { const value = this.value.replace(/,/g, ''); this.value = parseFloat(value).toLocaleString('en-US', { style: 'decimal', maximumFractionDigits: 2, minimumFractionDigits: 2 }); }); $('input.CurrencyInput2').on('blur', function() { const value = this.value.replace(/,/g, ''); this.value = parseFloat(value).toLocaleString('en-US', { style: 'decimal', maximumFractionDigits: 2, minimumFractionDigits: 2 }); }); $( ".fn" ).keyup(function() { var a = $('#a').val().replace(/,/g,''); var b = $('#b').val().replace(/,/g,''); var total = parseFloat(a) + parseFloat(b); $("#total_nya").val(parseFloat(total).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input class="CurrencyInput fn" id="a"> <input class="CurrencyInput2 fn" id="b"> <input class="total_nya" id="total_nya">
When parseFloat('2,500.00') will return 2 because of ,. parseFloat: parses its argument, and returns a floating point number. If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent, it returns the value up to that point and ignores that character and all succeeding characters remove , from value by using replace() function isNumberKey(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode(key); if (key.length == 0) return; var regex = /^[0-9.,\b]+$/; if (!regex.test(key)) { theEvent.returnValue = false; if (theEvent.preventDefault) theEvent.preventDefault(); } } function toFloat(z) { var x = document.getElementById(z); x.value = parseFloat(x.value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); } $( ".fn" ).keyup(function() { var nmi = $('#nmi').val().replace(/,/g,''); var a = $('#a').val().replace(/,/g,''); var total = parseFloat(nmi) + parseFloat(a); $("#total").val(parseFloat(total).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input onchange="toFloat('nmi')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="nmi" id="nmi"> <input onchange="toFloat('a')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="a" id="a"> <br> total <input onchange="toFloat('total')" type="text" maxlength="10" onkeypress="return isNumberKey(event)" required="required" class="form-control fn" placeholder="RM" name="total" id="total">
Simple for your change in code. $(document).ready(function() { $('.fn').on('input', function() { this.value = this.value.match(/^\d+\.?\d{0,2}/); calculate(); }); }); function calculate() { var t = 0; nmi = ($("#nmi").val() ? parseFloat($("#nmi").val()) : 0); a = ($("#a").val() ? parseFloat($("#a").val()) : 0); $("#total").val(nmi + a); } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="text" maxlength="10" required="required" class="form-control fn" placeholder="RM" name="nmi" id="nmi"> <input type="text" maxlength="10" required="required" class="form-control fn" placeholder="RM" name="a" id="a"> <br> total <input type="text" maxlength="10" required="required" class="form-control fn" placeholder="RM" name="total" id="total">
add additional value to the total
I am looking for a way to add the value from (discount) and (quantity) to my total. As for discount part, the customer will need to enter the right code to receiver discount. And for quantity, when clicked at the checkbox, then change the quantity, the total will also follow. Can you guys help me out on this problem? thanks (sorry, my English is not good) function addItemPrice() { var total = 0; var count = 0; for (var i = 0; i < document.myform.item.length; i++) { if (document.myform.item[i].checked) { total = (total + document.myform.item[i].value * 1); // another way to convert string to number count++; } } return total; } var sh_prices = new Array(); sh_prices["standard"] = 10; sh_prices["express"] = 20; function getAddShipping() { var shippingPrice = 0; var theForm = document.forms["myform"]; var shipping = theForm.elements["shipping"] for (var i = 0; i < shipping.length; i++) { if (shipping[i].checked) { shippingPrice = sh_prices[shipping[i].value]; break; } } return shippingPrice; } function getCode() { var theForm = document.forms["myform"]; var discode = theForm.elements["discount"] if (discode == "UAC123") { alert("yes"); } else { alert("no") } } function getTotal() { var totalPrice = getAddShipping() + addItemPrice(); document.getElementById('Price').innerHTML = "the total price" + totalPrice; } <form name="myform"> Sickle $5 <input type="checkbox" name="item" value="5" onclick="getTotal(item)"> <input type="number" name="quantity"><br> Sickle $1 <input type="checkbox" name="item" value="1" onclick="getTotal(item)"> <input type="number" name="quantity" value="1"><br> Sickle $50 <input type="checkbox" name="item" value="50" onclick="getTotal(item)"> <input type="number" name="quantity" value="1"><br> Sickle $5 <input type="checkbox" name="item" value="5" onclick="getTotal(item)"> <input type="number" name="quantity" value="1"><br> Sickle $7 <input type="checkbox" name="item" value="7" onclick="getTotal(item)"> <input type="number" name="quantity" value="1"><br> Standard <input type="radio" name="shipping" value="standard" onClick="getTotal(shipping)" /> Express <input type="radio" name="shipping" value="express" onClick="getTotal(shipping)" /> <br> Discount code <input type="text" name="discount" size=15> <input type="button" id="code" value="check" onClick="getCode(code)"> <div id="Price"> </div> </form>
Javascript removes the decimals when adding numbers together
I have this script that adds the 4 numbers together but JS doesn't take into account the original decimal places. // Initial input form <form class="weight_form" data-ajax="false" method="post"> <input type="text" class="input_save" placeholder="save as.."/> <input type="text" id="lf" placeholder="enter LF lbs" value="" onkeyup="myFunction()"/> <input type="text" id="rf" placeholder="enter RF lbs" value="" onkeyup="myFunction()"/> <input type="text" id="lr" placeholder="enter LR lbs" value="" onkeyup="myFunction()"/> <input type="text" id="rr" placeholder="enter RR lbs" value="" onkeyup="myFunction()"/> <input type="submit" id="sub_save" value="save"/> // Section to display results <div id="bottom_section"> <input type="text" id="total" value=""/> <input type="text" id="cross" value=""/> <input type="text" id="ls" value=""/> <input type="text" id="bite" value=""/> </div> // JS script to perform action on the fly <script> function myFunction() { var lf = document.getElementById("lf"); var rf = document.getElementById("rf"); var lr = document.getElementById("lr"); var rr = document.getElementById("rr"); var lf = parseInt(lf.value); var rf = parseInt(rf.value); var lr = parseInt(lr.value); var rr = parseInt(rr.value); var lf_1 = lf*1; var rf_1 = rf*1; var lr_1 = lr*1; var rr_1 = rr*1; var total = lf_1 + rf_1 + lr_1 + rr_1; var cross = rf_1 + lr_1 / total; var ls = lf_1 + lr_1 / total; var bite = lr_1 - rr_1; $('#total').val(total); $('#cross').val(Math.round(cross)); $('#ls').val(Math.round(ls)); $('#bite').val(bite); }; </script> If I enter say 20.5 for each input in the "weight_form" (lf, rf, lr, rr) the total is 80 instead of 82. Why does it seem to always round down the value?
To handle floats in your form, use parseFloat instead of parseInt, when parsing your values from the input elements. Since you're using jQuery, you can simplify myFunction by selecting your fields and parse their values in one line: var lf = parseFloat($("#lf").val()); var rf = parseFloat($("#rf").val()); var lr = parseFloat($("#lr").val()); var rr = parseFloat($("#rr").val()); Example: function myFunction() { var lf = parseFloat($("#lf").val()); var rf = parseFloat($("#rf").val()); var lr = parseFloat($("#lr").val()); var rr = parseFloat($("#rr").val()); var lf_1 = lf * 1; var rf_1 = rf * 1; var lr_1 = lr * 1; var rr_1 = rr * 1; var total = lf_1 + rf_1 + lr_1 + rr_1; var cross = rf_1 + lr_1 / total; var ls = lf_1 + lr_1 / total; var bite = lr_1 - rr_1; $('#total').val(total); $('#cross').val(Math.round(cross)); $('#ls').val(Math.round(ls)); $('#bite').val(bite); }; <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <form class="weight_form" data-ajax="false" method="post"> <input type="text" class="input_save" placeholder="save as.." /> <input type="text" id="lf" placeholder="enter LF lbs" value="" onkeyup="myFunction()" /> <input type="text" id="rf" placeholder="enter RF lbs" value="" onkeyup="myFunction()" /> <input type="text" id="lr" placeholder="enter LR lbs" value="" onkeyup="myFunction()" /> <input type="text" id="rr" placeholder="enter RR lbs" value="" onkeyup="myFunction()" /> <input type="submit" id="sub_save" value="save" /> <div id="bottom_section"> <input type="text" id="total" value="" /> <input type="text" id="cross" value="" /> <input type="text" id="ls" value="" /> <input type="text" id="bite" value="" /> </div> </form>
How to calculate total price & grand total using keyup
hy all .. I have quetion about jquery keyup 1. how I can calculate total from quantity[] * price[] 2 how I can callculate grantotal from price[] I have try like this but not working Thanks $('input[name="qty[]"').each(function(index, value){ $('input[name="qty[]"').on('keyup',function(){ var tot = $('input[name="price[]"').val() * this.value; $('input[name="subT[]"').val(tot); // console.log($('input[name="qty[]"')); }) }); //}); $('input[name="qty[]').keyup(function () { var sum = 0; $('.subT').each(function() { sum += Number($(this).val()); }); $('#grandtotal').val(sum); });
Change this $('input[name="price[]"]') to $('input[name="price[]"]').val() So, it should look like this: $('input[name="qty[]"]').keyup(function() { $('input[name="prodid[]"]').each(function() { var subT = parseFloat($(this).val()) * parseFloat($('input[name="price[]"]').val()); $('input[name="total[]"]').val($(this).val() * $('input[name="price[]"]').val()); }); });
Try $('input[name="qty[]"]').keyup(function() { var total = (this.value * $(this).next('[name="price[]"]').val()) || 0; $(this).next().next('[name="total[]"]').val(total) var grand = 0; $('[name="total[]"]').each(function() { grand += +this.value || 0; }); $('[name="grand_total"]').val(grand) }).keyup(); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input name="prodid[]" type="hidden" value="116"> <input name="qty[]" type="text" value="1" maxlength="2" class="detailinformation--input qty"> <input name="price[]" type="hidden" value="5"> <input name="total[]" type="hidden" value=""> <input name="prodid[]" type="hidden" value="117"> <input name="qty[]" type="text" value="1" maxlength="2" class="detailinformation--input qty"> <input name="price[]" type="hidden" value="4"> <input name="total[]" type="hidden" value=""> <input name="grand_total" type="text" value="">