Hi I have following input which gets values and calls function fntotal to display total. The code works fine when values are changed. However when values are loaded in the form it does not display the total.
<input type="textssr" name="s{{=id}}" id="{{=id}}" value='{{=sAmount}}'
onchange="fntotal(this.form)" />
function fntotal(formObj) {
var total = 0;
total += parseInt(formObj.test1.value, 10)
total += parseInt(formObj.test2.value, 10)
total += parseInt(formObj.test3.value, 10)
total += parseInt(formObj.s1020.value, 10)
formObj.sum.value = total
}
What I need to so that input displays the total on form load and onchange as well? Please help thanks
Set an
onLoad
event listener to the<body>
tag.I think following code will do, it is combination of jquery & javascript
You have to include jquery lib if you have not included it first.
To do that put following in begining of your tag.
try writing your script code to calculate the sum right after the input tags like below