Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #439600

    Hello,

    I would like to make a greyed out / inactive checkbox in a form so the user can see the checkbox but is not able to select it. How can this be done?

    Cheers,
    Eric.

    #440274

    Hey EricSmeets!

    Thank you for using Enfold.

    You can add the attribute “disabled” via javascript. The theme automatically apply unique ids to each checkbox. The very first checkbox id will be “#avia_checkbox_1”. Use google inspector or firebug to get the correct checkbox or input id.

    Regards,
    Ismael

    #440283

    Ok, that makes sense. But how do I add the javascript? With the codeblock? And what code should I use. Sorry, I am not that technical.

    #440308

    Hi!

    Please turn on custom CSS field for ALB elements – http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/ and give your contact form a custom class and then add following code to Functions.php file in Appearance > Editor

    function add_disable_checkbox(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery('.your-custom-class input.input_checkbox').attr('disabled', true);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_disable_checkbox');

    Regards,
    Yigit

    #441463

    Ok, I enabled custom CSS for the ALB elements, I added the code to the Appearance –> Editor, and I named the contact form the custom class: your-custom-class (just for test sake).

    But nothing happens. Sorry for my noobness!

    Regards,
    Eric.

    #441621

    Hey!

    Do you mind creating a temporary admin login and posting it here privately? Please post the link to your page where you would like to have checkbox disabled as well.

    Cheers!
    Yigit

    #442447
    This reply has been marked as private.
    #442450

    Hi!

    Please review your page now. I added the code to functions.php file in Appearance > Editor and gave your contact form element a custom class.

    Cheers!
    Yigit

    #442970

    Ah yes, I got it. But this disables all the buttons in the form. When I look in the Google Inspector I can see this codepart for example for 1 checkbox:

    <input name="avia_zaterdag_18_juli_2015_1" class="input_checkbox " type="checkbox" id="avia_zaterdag_18_juli_2015_1" value="true" disabled="disabled">

    Imagine I want to disable this button, how would the code in the functions.php look then?
    I tried this: But that doesn’t work:

    function add_disable_checkbox(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery('.your-custom-class input.avia_zaterdag_18_juli_2015_1').attr('disabled', true);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_disable_checkbox');
    • This reply was modified 9 years ago by EricSmeets.
    #442973

    Hi!

    Please use following code

    function add_disable_checkbox(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery('.your-custom-class input[name="avia_zaterdag_18_juli_2015_1"]').attr('disabled', true);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_disable_checkbox');

    Regards,
    Yigit

    #442992

    Using that code still disables all the checkboxes in the form…

    #442996

    Hey!

    You have accidentally add the code to Style.css file. I removed it from there and edited the one inside Functions.php file and now only “Zaterdag 18 juli 2015” is disabled. Please review your website now

    Regards,
    Yigit

    #443067

    Yes, I understand now what I did wrong, got it! Thanks again Yigit!

    #443071

    Hi!

    You are welcome Eric, always happy to help :)

    Cheers!
    Yigit

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Greyed out / disabled checkbox’ is closed to new replies.