"checkbox"
Bootstrap 4.0.0 Snippet by lavan

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body> <div class="container"> <input type="text" id="txt1"> <input type="text" id="txt2"> <button onclick="add()">Add</button> <table class="table table-bordered"> <thead> <tr> <th><input type="checkbox" class="fstck" onclick="some(this)"></th> <th>Lastname</th> <th>Email</th> </tr> </thead> <tbody id="displ"> </tbody> </table> </div> <script> function add(){ var fst=document.getElementById('txt1').value var sec=document.getElementById('txt2').value document.getElementById('displ').innerHTML+="<tr><td><input type='checkbox' class='doit' onclick='clk(this)'></td><td>"+fst+"</td><td>"+sec+"</td></tr>" } function clk(ml){ var ckbx=document.getElementsByClassName('fstck') if(ml.checked==false){ for(var i=0;i<ckbx.length;i++){ ckbx[i].checked=false } } else{ for(var i=0;i<ckbx.length;i++){ ckbx[i].checked=true } } } function some(lavan){ var ac=document.getElementsByClassName('doit') if(lavan.checked){ for(var i=0;i<ac.length;i++){ ac[i].checked=true } } else{ for(var i=0;i<ac.length;i++){ ac[i].checked=false } } } </script> </body> </html>

Related: See More


Questions / Comments: