Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have three textbox.one 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;
document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees")=v.value;
 
}
 
Posted 25-Jan-13 9:17am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try:
document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees").value=v;
You have put .value on the wrong side.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 25-Jan-13 16:34pm
   
Correct, a 5.
—SA
Sergey Alexandrovich Kryukov at 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.
—SA
Rate this: bad
good
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:
document.getElementById("txt_remainingfees")=v.value;
 
What is v.value?! Should be:
document.getElementById("txt_remainingfees").value=v;
 
Besides, to get values from strings, you had to use parseInt(string):
http://www.w3schools.com/jsref/jsref_parseint.asp[^].
 
I would also advise to use jQuery. It would be:
 
total=parseInt($("#txt_totalfees"));
fees = parseInt($("#txt_payFees"));
result = $("#txt_remainingfees");
result.value = total.value - fees.value;
 
Please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^].
 
—SA
  Permalink  
v3

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

  Print Answers RSS
0 Maciej Los 614
1 OriginalGriff 410
2 CPallini 230
3 RyanDev 161
4 Hard_Rockz 125
0 OriginalGriff 5,784
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,009
3 Maciej Los 2,894
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2014
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