-
AuthorPosts
-
May 5, 2015 at 10:12 am #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.May 6, 2015 at 12:11 pm #440274Hey 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,
IsmaelMay 6, 2015 at 12:55 pm #440283Ok, 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.
May 6, 2015 at 2:26 pm #440308Hi!
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,
YigitMay 8, 2015 at 9:49 am #441463Ok, 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.May 8, 2015 at 4:35 pm #441621Hey!
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!
YigitMay 11, 2015 at 2:11 pm #442447This reply has been marked as private.May 11, 2015 at 2:17 pm #442450Hi!
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!
YigitMay 12, 2015 at 1:02 pm #442970Ah 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, 6 months ago by EricSmeets.
May 12, 2015 at 1:03 pm #442973Hi!
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,
YigitMay 12, 2015 at 1:59 pm #442992Using that code still disables all the checkboxes in the form…
May 12, 2015 at 2:06 pm #442996Hey!
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,
YigitMay 12, 2015 at 3:28 pm #443067Yes, I understand now what I did wrong, got it! Thanks again Yigit!
May 12, 2015 at 3:31 pm #443071 -
AuthorPosts
- The topic ‘Greyed out / disabled checkbox’ is closed to new replies.