462,027 Members | 626 Online Need help? Post your question and get tips & solutions from a community of 462,027 IT Pros & Developers. It's quick & easy.

# Javascript calculation help

 P: 6 Hi guys, I have run into a problem and I can't figure out what's happening or why this script won't work. I am a self-taught scripter and only know what I use really. Any help would be appreciated. OK, here's the problem: I have a total of 5 dollar fields that will be calculated into a 6th dollar field. An example of what I need is like -------- field1 + field2 + field3 + field4 * field5. The answer to all of that gets put into the 6th field, which will also need to be rounded to the nearest whole \$. The only thing I want rounded is the answer, not the individual fields themselves. Also, one thing that I know for sure is wrong (and something I don't know how to do) is the fact that all the fields are optional. Meaning, maybe there will be input in them, and maybe there won't. I just have no idea how to script that. Here's what I've got that isn't working-------------- Expand|Select|Wrap|Line Numbers var a = this.getField("LO"); var b = this.getField("PP"); var c = this.getField("AEC"); var d = this.getField("UM"); var e = this.getField("TOT"); event.value = Math.round(a.value+b.value+c.value+d.value*e.value);   I have tried putting the individual values into ( ) by themselves, which doesn't make a difference. ----------One thing that I noticed that was happening is that when you only enter a value in the first 2 fields, it would get multiplied by 10 for some reason. Then the 3rd field would bring it back to the correct answer, and then the 4th wouldn't have any effect. (Using the value of 1 in all fields.) So 1+1 would show, a total of 20. 1+1+1 would be 3. 1+1+1+1 would be 3. ---------- Any help would be appreciated guys. Thank you!!! Nov 1 '07 #1 