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
|
|
|
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>
===
|
|
|
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 |
|
|
|