Click here to Skip to main content
Sign Up to vote bad
good
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:17


2 solutions

Try:
document.getElementById("ctl00_ContentPlaceHolder1_TabContainer1_TabPanel1_txt_totalfees").value=v;
You have put .value on the wrong side.
  Permalink  
Comments
Sergey Alexandrovich Kryukov - 25 Jan '13 - 16:34
Correct, a 5. —SA
Sergey Alexandrovich Kryukov - 25 Jan '13 - 16:45
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
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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 325
1 Abhinav S 168
2 Sergey Alexandrovich Kryukov 150
3 Ron Beyer 100
4 Zoltán Zörgő 85
0 Sergey Alexandrovich Kryukov 8,386
1 OriginalGriff 6,596
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid