Totaling points [RESOLVED]

Hello,

I am attempting to create a form in which the submitter will select options from a checkbox field with points in the values fields. I would like to be able to total the values selected. Is this something possible through GF?

Hi Nina,

If I was tasked with this I would first search thru the published plugins for a ready solution. If none were found, I would write a small plugin to handle it.

Sorry I’m not familiar enuf with the existing plugin library, so I can’t help you there.

But if some custom code was needed, it’s quite a straightforward exercise:

For the form-page:

  1. Designate an Admin Label prefix to flag which fields are eligible.
  2. Define the field choice values to their desired numeric values.

For the PHP plugin code:

  1. Set filter for event on post-submit
  2. In handler function, total selected choice values of flagged fields

The last step depends on what you want to do with the sum


One approach would be to swap out a placeholder value in a field (HTML or Single Line for example) with the generated sum value, which would then display the sum with the form’s output (page, email, PDF).

Hope this helps.

Yes, you can do this. In your checkbox field, tick the box “show values” and then give each option a unique value. Then, add a number field to the form, and tick the box ‘Enable Calculation’. Then, for the formula, just sum all the options (using the drop down to insert the merge tags for each option.) The key is to use the :value modifier with each option. When you insert a merge tag, it will look like this by default:

{First Choice:1.1}

Change it to look like this:

{First Choice:1.1:value}

For my form with field one having one checkbox field and three options in the field, this is my completed formula:

{First Choice:1.1:value}+{Second Choice:1.2:value}+{Third Choice:1.3:value}

1 Like

Thank you very much for taking the time to answer my question! This is exactly what I needed to know!

1 Like

Thank you for your reply, but unfortunately, I am not familiar with how to write a plugin, and this advice is over my head.