vendredi 19 février 2016

How to loop through group of check boxes that have same class name?

I have dynamic table that has table cell with checkbox field. This fields are populated from DB so my table is dynamic. I would like to loop through checkboxes based on their class name. In that loop I want to check value for each check box. For example if value is equal 1 I want checkbox to be checked, if not unchecked. Alo I'm not sure if possible but I would like to set unique ID for each of these check boxes. Since my table is dynamic my fields need to have unique ID's. Here is example of my code:

<table>
    <thead>
        <tr>
            <th>#</th>
            <th>Time Slots</th>
            <th>Block</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td>~(SLOT_LABEL)</td>
            <td>
                <span>
                <input type="checkbox" name="CF-[Events]" class="block" id="block_"+Value that will make this ID unique. value="~(SLOT_ID)"/>
                </span>
            </td>
        </tr>
    </tbody>
</table>

Also in current language that I work with to read values from DB I have to use NAME tag. If anyone can help please let me know. Thank you.




Aucun commentaire:

Enregistrer un commentaire