Well somewhere you need to call the sum() function and if the data is meant to appear in the "total" div then the out = document.getElementById("output"); needs to be out = document.getElementById("total"); instead.

Appart from that I don't really understand the purpose of the script. You might be best stating what the main purpose behind such a script is and we may be able to better advise with more appropriate script advice.