Click here to Skip to main content
14,217,648 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100