Skip Navigation

[Resolved] Test if one item has been checked in a set of checkboxes

This thread is resolved. Here is a description of the problem and solution.

Problem:
Test if one item has been checked in a set of checkboxes

Solution:
you can use option attribute to target your checkboxes field specific checkbox.

For example:

[wpv-conditional if="( '[types field="filed-name" option="0"][/types]'  eq 'checkbox_value' )"]
Content
[/wpv-conditional]
  
[wpv-conditional if="( '[types field="filed-name" option="1"][/types]' eq 'checkbox_value' )"]
Content
[/wpv-conditional]

Another way is:

[types field="field-name" option="0" state="checked"] option 0 is checked[/types]
[types field="field-name" option="1" state="checked"]  option 1 is checked[/types]

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/test-if-one-item-has-been-checked-in-a-set-of-checkboxes/#post-919714

Relevant Documentation:

100% of people find this useful.

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by josephQ 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#919498

Hi there,

I've got a custom field that is comprised of 3 options (checkboxes), any of which might be checked / ticked. What's the best way to test for the presence of one (or all) of the values on the Layout when using conditional output syntax? How can I tell which boxes have been checked?

Thanks!

#919714

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can use option attribute to target your checkboxes field specific checkbox.

For example:

[wpv-conditional if="( '[types field="filed-name" option="0"][/types]'  eq 'checkbox_value' )"]
Content
[/wpv-conditional]
 
[wpv-conditional if="( '[types field="filed-name" option="1"][/types]' eq 'checkbox_value' )"]
Content
[/wpv-conditional]

Another way is:

[types field="field-name" option="0" state="checked"] option 0 is checked[/types]
[types field="field-name" option="1" state="checked"]  option 1 is checked[/types]
#920588

This worked splendidly, thank you!