Get count of checked items in a dynamic field as default value for number field

By: Flo Ubr | Asked: 12/03/2022
ForumsCategory: General questionsGet count of checked items in a dynamic field as default value for number field
Flo Ubr asked 1 year ago

I have 2 fields:

1. dynamic field listing items with checkboxes - source is another 3rd field  

2. simple number field; for "Default Value" I want to calculate the count of selected items from above dynamic field. – Is this possible? Does field calculation allow for such functionality?    

Attachments
2 Answers
Best Answer
Victor Font answered 1 year ago
You need to use jQuery. https://formidableforms.com/knowledgebase/javascript-examples/#kb-count-number-of-checked-boxes
Flo Ubr replied 1 year ago

Thank you!

Luke M answered 1 year ago
What about checkboxes with "other" option(s) available ? 
Flo Ubr replied 1 year ago

not sure if I understand your question/hint… but the answer by Victor to use a javascript worked.

Luke M replied 1 year ago

Doesn`t work for checkboxes where "other" option is to be typed by the user (checkbox with custom text). It will not be count when it`s checked.

Victor Font replied 1 year ago

The "other" option is a checkbox that will be counted if you modify the jQuery example to do so. The jQuery looks at a checkbox's name and checked properties to determine the count. The selector for regular checkboxes is input[name='item_meta[643][]']:checked. To check for other, include input[name='item_meta[643][other_2]']:checked in the selector list like this modified example on pastebin: https://pastebin.com/rXYYBhHc

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right