Pergunta

Can a checkbox in Contact Form 7 (Wordpress plugin) be disabled?

I have a group of 5 checkboxes, and I want one to be there, but disabled (not clickable, not selected).

How to do it?

Foi útil?

Solução

Add an id to your to your checkbox. It will look something like this, it is important that the id is after the variable as shown below.

[checkbox variable  id:disablethis "variable"]

This will put the id "disablethis" on the span tag that surrounds your checkbox (input) that you are trying to disable. Then we can simply find that span and disable all of the inputs within it like so. Put this at the bottom of your form/page.

<script>
$("#disablethis :input").attr("disabled", true);
</script>

Outras dicas

you can disable it by using jQuery like this :

jQuery('#checkbox').attr('disabled','disabled');

where #checkbox is the ID of checkbox.

Thanks a million ImTheMechanic! I was looking for a few days how to reference the checkbox and set its state (checked or unchecked). I had to put :input after the id. I could never have guessed!

I did it like this:

if (dayNameB == "zaterdag") {
        $("#brengtijdzat").show();
        $("#brengtijdzat :input").prop("checked", true);
        $("#brengtijd").hide();
        $("#brengtijd :input").prop("checked", false);
    }`

Thanks!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top