Conditional logic – only show submit button when ANY option selected from radio

Home Forums Quform WordPress Conditional logic – only show submit button when ANY option selected from radio

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20268
    kendavies
    Participant

    Hi,
    First off, great plugin.

    I need to ask for advice Is there is a way to use conditional logic to display the submit button when ANY option selected from radio button in a group? As the radio button options will be conditional on the first 2 options they could end up being numerous.

    So an example function would be:

    > Sector: Education
    > Role: Director
    > Radio list: [ANY]
    = display “submit” button

    Here is a link to the current dev. http://bit.ly/2fz98vf

    Currently I am using the code which allows the submit on selection of a particular option value. Found at https://support.themecatcher.net/quform-wordpress/guides/advanced/submit-button-conditional-logic

    <script>
    jQuery(document).ready(function ($) {
    var $choices = $(‘.iphorm_1_1’);

    function checkConditions()
    {
    if ($choices.filter(‘:checked’).val() == ‘Yes’) {
    $(‘.iphorm-submit-wrap-1’).show();
    } else {
    $(‘.iphorm-submit-wrap-1’).hide();
    }
    }

    $choices.click(checkConditions);
    checkConditions();
    });
    </script>

    Thanks and I look forward to any suggestions

    #20277
    support
    Moderator

    Hi,

    I suggest you ocount the number of radio buttons checked to show the submit button. You could use something like this (notice that I’m using multiple selector) :


    <script>
    jQuery(document).ready(function ($) {
    var $choices = $('.iphorm_1_1, .iphorm_1_8, iphorm_1_12');

    function radioClicked()
    {
    if ($choices.filter(':checked').length > 0) {
    $('.iphorm-submit-wrap-1').show();
    } else {
    $('.iphorm-submit-wrap-1').hide();
    }
    }

    $choices.click(radioClicked);
    radioClicked();
    });
    </script>

    Hope this helps,
    Regards,

    Félix

    #20310
    kendavies
    Participant

    That worked perfectly, exactly what I needed. Thanks Félix.

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