Count form results and update database


My application has a number of dropdown lists. I’d like to count how many times different values have been selected in a form and add to a field in database.

I was thinking that i would add 3 new fields to my model. Yes, No and Unanswered and then somehow calculate how many times these we selected and update database with the total.

So basically:
Yes | No | Unanswered
5 | 5 | | 7

What would be the best way to do this? Maybe i would need client side method to count and then update a field in the form before Posting form to database?


You’re looking at collecting this type of data across a number of submittals?

Are you keeping all the individual form submissions? If so, you’re a lot better off calculating those results on an as-needed basis than trying to maintain running totals.

(It might be easier to explain if you posted the model and form involved in this.)

Hi Ken,

Thanks again for replying.

I’ve worked round this using JS which populates the 3 fields. Then when the form is POST it updates the database.