Base Conditional Field on Prepopulated Dropdown Selection

Home Forums Quform WordPress Base Conditional Field on Prepopulated Dropdown Selection

This topic is: resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #27281
    jerkski
    Participant

    Hello, 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

    #27294
    jerkski
    Participant

    I 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?

    #27295
    Ally
    Support Staff

    You 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 2 years, 4 months ago by Ally.
    #27299
    jerkski
    Participant

    Hi Ally, thank you for the quick response, Yes, I do need the hidden field to be required if visible.

    #27307
    jerkski
    Participant

    Ally, 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>
    #27308
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #27396
    jerkski
    Participant

    Thank you Ally! That worked wonderfully!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy