Home › Forums › Quform WordPress › Base Conditional Field on Prepopulated Dropdown Selection
- This topic has 6 replies, 2 voices, and was last updated 6 years, 8 months ago by
jerkski.
- AuthorPosts
- October 22, 2018 at 8:40 pm #27281
jerkski
ParticipantHello, I have a dropdown field that pulls its options from Mysql using a custom function. In that list, mysql returns an option value of ‘OTHER’. I am trying to create a text field that conditionally appears and is required anytime someone chooses ‘OTHER’ in the prepopulated dropdown, but am unable to do so since the options are not defined in the backend of Quform. Therefore they do not show up in the conditional field settings. How can I set the conditional in a function?
I am using Quform v1.82
October 23, 2018 at 2:40 pm #27294jerkski
ParticipantI tried a variation of the jQuery you have on this link, but it did not work. (https://support.themecatcher.net/quform-wordpress/guides/advanced/submit-button-conditional-logic)
<script> jQuery(function ($) { $('.iphorm_1_1').change(function () { if ($(this).val() == 'OTHER') { $('.iphorm_1_2').show(); } else { $('.iphorm_1_2').hide(); } }).change(); }); </script>
Thoughts?
October 23, 2018 at 2:46 pm #27295Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 6 years, 8 months ago by
Ally.
October 23, 2018 at 3:12 pm #27299jerkski
ParticipantHi Ally, thank you for the quick response, Yes, I do need the hidden field to be required if visible.
October 23, 2018 at 7:59 pm #27307jerkski
ParticipantAlly, is it possible to set the required function within the script as you’ve written?
<script> jQuery(function ($) { $('.iphorm_1_1').change(function () { if ($(this).val() == 'OTHER') { $('.iphorm_1_2').closest('.iphorm-element-wrap').show(); //set to required here } else { $('.iphorm_1_2').closest('.iphorm-element-wrap').hide(); //unset required here } }).change(); }); </script>
October 23, 2018 at 8:15 pm #27308Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
October 24, 2018 at 3:31 pm #27396jerkski
ParticipantThank you Ally! That worked wonderfully!
- This reply was modified 6 years, 8 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.