vendredi 1 janvier 2016

When I check one checkbox, I want another similar checkbox to be ticked

I would like to add a feature to my current project that enables the user to only have to check a checkbox with the same content once. In my case, I have a recipes page with checkboxes of ingredients for each recipe to use while shopping and I would like to have it so that when the user checks the checkbox "Coriander" in one recipe, it also checks any other Coriander checkbox in any other recipe.

At the moment I am working with ids and labels, but this only works for unique ids obviously.

    <input type="checkbox" class="checkbox2"><label for="checkbox2"> Coriander</label> <br>

My current idea is to use the same snippet of code as for un/check all type buttons, but instead use a class of Coriander rather than id but not sure that would work or if it is the most elegant way.

Any other ideas appreciated!




Aucun commentaire:

Enregistrer un commentaire