dimanche 7 juillet 2019

How can I set dynamic checkbox in web page

How can I set the dynamic checkbox into table rows when the data given from a modal using java script

function CreateCheckBox(){

//Second create a row
var row = document.tbody.tr;
row.className = 'gridrow';

//Third create td element
td = document.tbody.tr.td;
td.className = 'gridcell';

td.rowSpan = 1;
td.style.width = '80px';

//fourth create checkbox in that td element
var chkbox = document.createElement('input');
chkbox.type = "checkbox";
chkbox.id = "chk" ;
chkbox.name = "chk" ;

//Fifth add checkbox to td element
td.appendChild(chkbox);
//Add a td into a row
row.appendChild(td);
//Finally added to the form to print

}

                <th>CID</th>
                <th>Name</th>
                <th>Address</th>
                <th>TP</th>

            </tr>
            </thead>
            <tbody id="tableB" data-toggle="checkbox" onclick="CreateCheckBox()">

            </tbody>
        </table>

but I cant get check box when the entered data from a model in web page




Aucun commentaire:

Enregistrer un commentaire