Posts: 339
Threads: 42
Joined: Apr 2010
Reputation:
2
I'm looking to calculate the sum of several fields and input that number into another field as a total.
I'm thinking of using the submission pre-parser to do this, as I want it to calculate the fields upon submission (or update) and then input the total into the total field. There's no need for the person submitting the form to see the total, just need it on the back end.
Before I get going on trying to figure it out, has anyone done this?
Alex
Posts: 339
Threads: 42
Joined: Apr 2010
Reputation:
2
Not yet but I was planning on working on this again in the next week or two. My plan is to use the submission pre-parser. I'll definitely post if I get it working!
Posts: 339
Threads: 42
Joined: Apr 2010
Reputation:
2
I ended up finding an easier solution with jQuery I think (sorry this was a while ago!) but I know I never figured out how to do it with the submission pre-parser. Maybe smoring got it working!
Posts: 339
Threads: 42
Joined: Apr 2010
Reputation:
2
I think I did it client side using jquery, putting the calculated total in another field. It may have been a hidden field. Let me do a little research and I'll find where I used this.
Posts: 16
Threads: 2
Joined: Jul 2012
Reputation:
0
I know you found your solution through jQuery, but I just thought I would add my 2 cents as I do use the pre-parser for calculations. And someone may need the information in the future.
Mine is setup to calculate on submission and edit for one particular form that I use for tracking QA scores. I am using to rounding function to limit the decimal places. Below is the php code.
$setid = $_POST["$submission_id"];
print_r($setid);
exit;
mysql_query("UPDATE live_form_9 SET `score`=Round((score1+score2+score3+score4+score5+score6+score7)/35*100,2) WHERE submission_id = '$setid'");}