• Resolved sueblue

    (@sueblue)


    I have the following form that works on another Form plugin.
    I cannot have it work with Contact Form 7.

    What it is supposed to do: When Type 2 client is selected, Services 4 and 5 should be hidden.

    What is happening: Services 4 and 5 are being hidden for both Type 1 and Type 2 clients.

    HTML (just part of the form)

    <div class="b-input__wrapper">
        <h3 class="b-form-long-text no-padding">Customer Type</h3>
        <div class="b-changed-radios">
    
            <div class="b-checkbox-wrapper_half">
                [radio customer-type default:1 id-item:type_1 "Type 1"]
            </div>
            <div class="b-checkbox-wrapper_half">
                [radio customer-type id-item:type_2 "Type 2"]
            </div>
    
        </div>
    </div>
    <div class="b-input__wrapper" id="checkbox-wrapper">
    <h3 class="b-form-long-text no-padding">Service Type</h3>
        <div class="b-checkbox-wrapper">
            <div class="b-checkbox-wrapper_half">
                [checkbox service-type id-item:service_1 "Service 1"]
            </div>
            <div class="b-checkbox-wrapper_half">
                [checkbox service-type id-item:service_2 "Service 2"]
            </div>
            <div class="b-checkbox-wrapper_full">
                [checkbox service-type id-item:service_3 "Service 3"]
            </div>
            <div class="b-checkbox-wrapper_half hidden">
                [checkbox service-type id-item:service_4 "Service 4"]
            </div>
            <div class="b-checkbox-wrapper_half hidden">
                [checkbox service-type id-item:service_5 "Service 5"]
            </div>
        </div>
    </div>

    Here is the js part

    function changeRadios() {
                if($('#type_1').is(':checked')) {
                    $('#checkbox-wrapper').css({'display': 'block'});
                    $('.b-checkbox-wrapper_half.hidden').css({'display': 'block'});
                    $('.b-checkbox-wrapper_half.hidden input').removeAttr('disabled');
                }
                if($('#type_2').is(':checked')) {
                    $('#checkbox-wrapper').css({'display': 'block'});
                    $('.b-checkbox-wrapper_half.hidden').css({'display': 'none'});
    		   	    $('.b-checkbox-wrapper_half.hidden input').attr('disabled', 'disabled');
                }
            }
    
            changeRadios();
    
            $('.b-changed-radios').on('change',function() {changeRadios()});

    https://wordpress.org/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Show/Hide fields with Javascript not working’ is closed to new replies.