Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working on invoice Project and that i need to get nettotal value of Invoice ,

i have a tota value which comes from quentity * Rate

$(function () {
			$("#PerchesQty,#PerchesRate").keyup(function (e) {
				var pqty = $("#PerchesQty").val();
				var Prate = $("#PerchesRate").val();
				var result = "";
				if (pqty !== "" && Prate !== "" && $.isNumeric(pqty) 
                                 && $.isNumeric(Prate)) {
					result = parseFloat(pqty) * parseFloat(Prate);
				}
				$("#Total").append(result);
				$("#Total").val(result);

			});
		});

and its Works well

but when i tryed get netTotal=netTotal+total its not works

What I have tried:

$(document).ready(function () {
			$("#Total").change(function () {
				var tot = $("#Total").val();
				var gtot = "";
				var xnet = $("#NetTotal").val();
				debugger;
				if (xnet > "0.00") {
					if (tot !== "" && xnet == "" && $.isNumeric(tot) && $.isNumeric(xnet)) {
						gtot = parseFloat(tot) + parseFloat(xnet);
					}
				}
				else {
					gtot = $("#Total").val();

				}
				$("#NetTotal").append(gtot);
				$("#NetTotal").val(gtot);
				//alert($("#NetTotal"))
			});
		});
Posted
Updated 31-Jan-19 22:03pm

1 solution

Although there could be multiple reasons which I cannot figure out from the lack of context (i.e. whether those fields in quesion present, how exactly it does not wor etc) still I see this line
if (xnet > "0.00")

as highly suspicious. You compare string variable with greater operator which might work not as you expect it.
I suggest you to parse if and only then compare to 0.0 if it's really what you need to do
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900