Skip Navigation

[Résolu] Disable single checkbox on form with multiple checkboxes field.

This support ticket is created Il y a 2 années et 1 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Marqué : 

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par peterJ-3 Il y a 2 années et 1 mois.

Assisté par: Waqar.

Auteur
Publications
#2485193

Tell us what you are trying to do?

I need to disable single checkbox on form with multiple checkboxes field. Specifically the first checkbox (labelled Day 1) on this form. lien caché

I have looked at doing this via jquery, but the ID for each field is auto-generated and not consistent.

#2485649

Hi,

Thank you for contacting us and I'd be happy to assist.

To disable the first checkbox of that field, you can structure your jQuery code like this:


jQuery(document).ready(function( $ ) {
  $('ul.wpt-form-set-checkboxes-wpcf-attendance-days > li:first input').attr("disabled", true);
});

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#2485669

Hmmm. That didn't work.

I added the code like this in the JS field on the Toolset form:

(function( $ ) {
    "use strict";
  
  jQuery(document).ready(function( $ ) {
    $('ul.wpt-form-set-checkboxes-wpcf-attendance-days > li:first input').attr("disabled", true);
  });

});
#2486763

I apologize for the delay in getting back on this, as we had an unusually busy forum queue over the weekend.

Can you please test it without wrapping it within another function, like the way I shared? It should work that way.

#2486931

Prefect. Thank you so much. Sorry. I wrapped it in a function as a habit.