Hi gang, I have a small issue I can't get my head around.
I have a questionnaire with about 20 questions on it. Each response to a question has a numerical score and in it's own column in the database. That part is easy.
In an extra column I need to add the total score to it. What would be the best way to get a final score added to the last column?
If client side I would create a variable and set it to contain the sum of all the answers.
If server side then I would do a query to handle it once the data has been updated. You could update the record as each question is answered which would also enable the visitor to come back later to a partly completed form.
Thanks Jon, I think client side will work for this purpose so I can display the current score. How do I get the sum though? I am thinking I also need to add the total to a hidden form field so I can enter it in the database record?
I'd carry this out using a view in the database. Just chuck your table holding the results in to an LLM and get it to pump it out for you. Just remember to account for nulls as 0 and that way will always get a total.
This would mean updating the data after every question. If you're doing that then that's the best way.
Is there a need for security? I mean, if you did it all client-side and stored the total in a variable then it's open to manipulation but if you're not concerned about that then you can just have a hidden input which contains the value of the variable. Or you can do the sum server-side to store the total which would mean that even if manipulated client-side it wouldn't matter.
The easiest way to get the total into the variable is to set it's value from the question inputs added together.
No need to worry about security. It's for an internal assessment tool. Most of our staff wouldn't even know how or that there even is a developer console.