mardi 14 juillet 2015

select all checkboxes in jquery not triggered properly

I want to set values of selected checkbox to text input

For example: see this image Click

Problem is when i click "Select All" checkbox "child" checkboxes are checked but value not set in textbox and values set when i uncheck the "Select All" checkbox

I want to get checkbox values in array so i am using map function,

Please see jquery on fiddle

fiddle here

HTML CODE

<form action="" id="form">
    <input type="checkbox" id="selectAll">
    <label for="selectAll">Select All</label><br>

    <div class="child">
        <input type="checkbox" class="selectCb" value="1" id="one">
        <label for="one">One</label><br>
        <input type="checkbox" id="two" class="selectCb" value="2">
        <label for="two">Two</label><br>
        <input type="checkbox" class="selectCb" value="3" id="three">
        <label for="three">Three</label><br>
    </div>


    <input type="text" id="textBox">
</form>




Aucun commentaire:

Enregistrer un commentaire