{"id":16047001,"date":"2022-09-27T10:12:16","date_gmt":"2022-09-27T10:12:16","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/multiple-conditional-elements\/"},"modified":"2022-09-27T10:12:16","modified_gmt":"2022-09-27T10:12:16","slug":"multiple-conditional-elements","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/multiple-conditional-elements\/","title":{"rendered":"Multiple conditional elements"},"content":{"rendered":"<p>Dear support team,<\/p>\n<p>thank you very much for the great plugin. I recently switched from CF7 and its great!<\/p>\n<p>I am trying to build out a condtional forms that is a little bit more complicated. I would like to use two fields with <code>data-show-if<\/code>, something like <code>data-show-if:FIELD-1:value-1 FIELD-2 value-2<\/code>, but I dont think that is possible? At least I tried different combinations and none of them worked.<\/p>\n<p>To give you some background on what I am trying to achive: I have a chained select like car makers and models. But the lists are incomplete so user should be able so select &#8220;other&#8221; and in this case a text field is shown to input another maker or model. For the model it works great. I can just add a text input field with <code>data-show-if:MODEL:Other<\/code>. But for the MAKER it is more complicated, because the text inputs for <code>MAKER_OTHERS<\/code> and <code>MODEL_OTHERS<\/code> need to be shown (and MODEL needs to be hidden, which works fine).<\/p>\n<p>A reduced example of the code, without the Javascript to make the chained select possible.<\/p>\n<pre><code>\n&lt;p&gt;\n\t&lt;label for=&quot;MAKER&quot;&gt;Maker&lt;\/label&gt;\n\t&lt;select name=&quot;MAKER&quot; required id=&quot;MAKER&quot;&gt;\n        &lt;option&gt;Audi&lt;\/option&gt;\n        &lt;option&gt;Ford&lt;\/option&gt;\n        &lt;option&gt;Other&lt;\/option&gt;\n    &lt;\/select&gt;\n&lt;\/p&gt;\n&lt;p data-hide-if=&quot;MAKER:Other&quot;&gt;\n\t&lt;label for=&quot;MODEL&quot;&gt;Maker&lt;\/label&gt;\n\t&lt;select name=&quot;MODEL&quot; required id=&quot;MODEL&quot;&gt;\n        &lt;option&gt;A1&lt;\/option&gt;\n        &lt;option&gt;A2&lt;\/option&gt;\n        &lt;option&gt;Fiesta&lt;\/option&gt;\n        &lt;option&gt;F-150&lt;\/option&gt;\n        &lt;option&gt;Other&lt;\/option&gt;\n    &lt;\/select&gt;\n&lt;\/p&gt;\n\n&lt;p data-show-if=&quot;MAKER:Other&quot;&gt;\n\t&lt;label for=&quot;MAKER_OTHERS&quot;&gt;Maker (others)&lt;\/label&gt;\n\t&lt;input type=&quot;text&quot; name=&quot;MAKER_OTHERS&quot; required id=&quot;MAKER_OTHERS&quot; \/&gt;\n&lt;\/p&gt;\n&lt;p  data-show-if=&quot;MODEL:Other MAKER:Other&quot;&gt;\n\t&lt;label for=&quot;MODEL_OTHERS&quot;&gt;Model (others)&lt;\/label&gt;\n\t&lt;input type=&quot;text&quot; name=&quot;MODEL_OTHERS&quot; required id=&quot;MODEL_OTHERS&quot; \/&gt;\n&lt;\/p&gt;\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-16047001","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16047001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16047001\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16047001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}