Skip Navigation

[Resolved] Conditional display if option from multi checkbox is checked

This support ticket is created 2 years, 12 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by simchaH 2 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2255103
Screenshot (44).png

Hi,

I am searching for the correct conditional statement for checking whether a checkbox is checked as part of a multi-checkbox. (I don't care if there are many options checked, only that this specific option MUST be checked in order to display the text I want)

I tried this:

[wpv-conditional if="( '[types field='conference-categories' option='9'][/types]' eq '10' )"]
TEST STRING
[/wpv-conditional]

from this thread: https://toolset.com/forums/topic/conditional-display-depending-on-checkbox-2/

and also this:
{!{wpv-conditional if="( '[types field='schutzart-ip' option='0'][/types]' eq 'ip66' ) AND ( '[types field='schutzart-ip' option='1'][/types]' eq 'ip67' )" debug="true"}!}
TEST
{!{/wpv-conditional}!}

from this thread: https://toolset.com/forums/topic/conditional-output-based-on-multiple-checkboxes/#post-1225586

But neither of them worked for me. See my screenshot, I swapped out the field value above for "contact-role", left in option= "0" because it is the first in the list of checkbox options, and made it to eq "Rabbi".

Can you let me know if there's something I'm missing?

Thanks!

#2255233

Hello,

I suggest you try the types shortcode with attributes "option" + "unchecked", like this:

[types field="my-checkboxes" option="0" state="unchecked"]First option checked[/types]
[types field="my-checkboxes" option="1" state="unchecked"]Second option checked[/types]

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

#2255475

Thanks for the quick response,

so for me it would look like this:

[types field="contact-role" option="0" state="checked"][types field="first-name"] [/types][types field="last-name"][/types]

The shortcode works in that it displays the first and last name for the option "0" that is checked, but it also doesn't work. It also displays only the last name of every related post, which is super strange.

To elaborate so you understand exactly what is going on, this shortcode is being put inside a content template (legacy, not block editor) loop-view, which is being nested inside another (parent) loop-view. The parent loop of each post is the location, and this nested loop is supposed to show the first and last name of people that are connected to the location, (the query filter I set up for it is: Locations to People relationship that are a related to the current post in the loop.) - But I want only the people with this specific option checked (option "0") to display- it is a one to many relationship where many people can be connected to one location. So for some reason this shortcode is adding in everyone that is connected to the location, displaying the first and last name for option 0, and only displaying the last name for the rest of the related people in the location.

Any idea how this can be happening?

#2255729

You are using wrong codes, please try to modify it as below:

[types field="contact-role" option="0" state="checked"]
[types field="first-name"] [/types][types field="last-name"][/types]
[/types]

And test again

#2256017

Now it is showing up with the word [/types] at the end of each name that is being displayed.
ie: "Doe [/types] Smith [/types]" etc.

#2257997

Please try these shortcode, and test again:

[types field="contact-role" option="0" state="checked"]
[types field="first-name"] [types field="last-name"]
[/types]
#2258027

Thanks Luo!

My issue is resolved now. Thank you!