CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Editable Grid - javascript Sum function

Print topic Send  topic

Author Message
jerrym

Posts: 52
Posted: 10/17/2008, 12:50 AM

hi all

i'm hoping someone can help me with the code below.

i need to total a column's values (some rows in the column may be Null) to a read only textbox at the bottom of an editable grid. i placed an onchange event to user input textbox which fires the code below;

javascript code
===
function RecalcMon(strvalue) {
initTempTimesheetDetailsElements();
var amt = 0;
var tmp = 0;
//for (var j = 1; j<document.TempTimesheetDetails.Elements.length; j++) {
for (var j = 1; j <TempTimesheetDetailsElements.length-TempTimesheetDetailsEmptyRows; j++) {
amt = amt + parseFloat(document.getElementById("TempTimesheetDetailsMon_" + j).value);

}
document.TempTimesheetDetails.SumMon.value = amt
//document.getElementById("SumMon").innerText = amt
//document.write (amt)
}
</script>
===

first im getting an error when the onchange fires msg is "Object expected line 53" this line is referring to " initTempTimesheetDetailsElements(); "

2ndly, im not sure how to overcome a row with null values in the code

any help is much appreciated.

regards
Jerry
View profile  Send private message
jerrym

Posts: 52
Posted: 10/17/2008, 10:13 PM

hi all

for those that have a similar problem, here's the solution.

js code
===
function RecalcMon(controlname) {
var FormState = document.TempTimesheetDetails.FormState.value.split(";");
var AllLength = parseInt(FormState[0])+parseInt(FormState[1]);
var amt = 0;
var tmp = 0;

for (var j = 1; j<AllLength; j++) {
tmp = parseFloat(document.getElementById("TempTimesheetDetailsMon_" + j).value);
if (isNaN(tmp) == true)
tmp = 0;
else
amt = amt + tmp;
}
document.TempTimesheetDetails.SumMon.value = amt
}
</script>
===
View profile  Send private message
Oper


Posts: 1195
Posted: 10/19/2008, 6:31 AM

controlname parameter not used why?

did not work with parameter and has t be done hardcore?


Thank for sharing
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.