To calculate total amount

I have a doctype which having some amount fields,i want to calculate the total amount…

and i am using the custom script like this

Trigger this function on refresh instead of total
ie refresh: function(frm, cdt, cdn) {

Thank you for you reply…
But it is still not updating and showing zero as total …
The doctype i am adding u…

If you want to update total in real time you have to make this a function and call that on every field that affects the total amount. or you can calculate the total on before_save the form. There is already a trigger named ‘before_save’, you can use that.

soory to bother u…i changed it but still not working

Please note that you have to reload the page in order to be new js script to be effective.