Click here to Skip to main content
12,999,837 members (51,934 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have three for totalfees.second for payfees.third for remainingfees.

totalfees is filled already when page load.payfees i have to enter.when i leave from textbox remainigfees calculated automatically.
for this i have to use javascript.i have try this..but i think i have problem in my javascript function.please help me.


function RemainingFees()
var v1=document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees");
var v2=document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_remainingFees");
var v=v1.value-v2.value;
Posted 25-Jan-13 9:17am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


You have put .value on the wrong side.
Sergey Alexandrovich Kryukov 25-Jan-13 16:34pm
Correct, a 5.
Sergey Alexandrovich Kryukov 25-Jan-13 16:45pm
However, something else is missing before this line.
Before doing integer arithmetic operations, strings should be parsed with JavaScript parseInt(string).
Please see my answer. Your answer is of course credited...

And I deleted OP's re-post where I initially saw this question and answered. Tnank you for notification on this re-post.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In addition to correct answer by Zoltán Zörgő:

First bug I can see immediately:

What is v.value?! Should be:

Besides, to get values from strings, you had to use parseInt(string):[^].

I would also advise to use jQuery. It would be:

fees = parseInt($("#txt_payFees"));
result = $("#txt_remainingfees");
result.value = total.value - fees.value;

Please see:[^],[^].


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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