Multiple conditional elements
-
Dear support team,
thank you very much for the great plugin. I recently switched from CF7 and its great!
I am trying to build out a condtional forms that is a little bit more complicated. I would like to use two fields with
data-show-if
, something likedata-show-if:FIELD-1:value-1 FIELD-2 value-2
, but I dont think that is possible? At least I tried different combinations and none of them worked.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 “other” 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
data-show-if:MODEL:Other
. But for the MAKER it is more complicated, because the text inputs forMAKER_OTHERS
andMODEL_OTHERS
need to be shown (and MODEL needs to be hidden, which works fine).A reduced example of the code, without the Javascript to make the chained select possible.
<p> <label for="MAKER">Maker</label> <select name="MAKER" required id="MAKER"> <option>Audi</option> <option>Ford</option> <option>Other</option> </select> </p> <p data-hide-if="MAKER:Other"> <label for="MODEL">Maker</label> <select name="MODEL" required id="MODEL"> <option>A1</option> <option>A2</option> <option>Fiesta</option> <option>F-150</option> <option>Other</option> </select> </p> <p data-show-if="MAKER:Other"> <label for="MAKER_OTHERS">Maker (others)</label> <input type="text" name="MAKER_OTHERS" required id="MAKER_OTHERS" /> </p> <p data-show-if="MODEL:Other MAKER:Other"> <label for="MODEL_OTHERS">Model (others)</label> <input type="text" name="MODEL_OTHERS" required id="MODEL_OTHERS" /> </p>
- The topic ‘Multiple conditional elements’ is closed to new replies.