lundi 29 août 2016

Parent and child grandchild checkboxes

<div class="col-lg-3 col-xs-3 col-left">
            <h4>Topics</h4>
            <div class="checkbox">
                <label>
                    <input type="checkbox" value="1" checked> mCRC
                </label>
            </div>
            <div class="checkbox ml10">
                <label>
                    <input type="checkbox" value="2" data-parent="1" id="stivarga-efficacy" checked> STIVARGA Efficacy
                </label>
            </div>
            <div class="checkbox ml20">
                <label>
                    <input type="checkbox" value="3" data-parent="1,2" id="long-term" checked> Long-Term Responders
                </label>
            </div>
            <div class="checkbox ml20">
                <label>
                    <input type="checkbox" value="4" data-parent="1,2" id="stivarga-in-clinical" checked> STIVARGA in Clinical Practice
                </label>
            </div>
            <div class="checkbox ml10">
                <label>
                    <input type="checkbox" value="5" data-parent="1" checked> STIVARGA AE Management
                </label>
            </div>
            <div class="checkbox ml10">
                <label>
                    <input type="checkbox" value="6" data-parent="1" checked> Dosing
                </label>
            </div>
            <div class="checkbox ml10">
                <label>
                    <input type="checkbox" value="7" data-parent="1" checked> Patient Communication
                </label>
            </div>
            <div class="checkbox ml10">
                <label>
                    <input type="checkbox" value="8" data-parent="1" checked> Case Studies
                </label>
            </div>

            <div class="checkbox">
                <label>
                    <input type="checkbox" value="9" checked> GIST
                </label>
            </div>

        </div>

There are some checkboxes on a page.I have need:

  1. Check all childs if parent is checked.
  2. Uncheck parent if all childs are unchecked.
  3. Check parent if at least one child is checked.

How can I accomplish this ? I found a solution here Parent and child checkboxes it, I am having problem with the grand child functionality

codepen http://ift.tt/2c6ve42




Aucun commentaire:

Enregistrer un commentaire