Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.93 KB | None | 0 0
  1. <!Doctype HTML>
  2. <html>
  3. <head>
  4.     <title></title>
  5.     <Style type="text/css">
  6.         .TestDiv
  7.         {
  8.             color: black;
  9.             padding: 5px;
  10.             margin: 5px;
  11.             table-layout: fixed;
  12.  
  13.         }
  14.         .tbl {
  15.             border-collapse: collapsed;
  16.         }
  17.         .tbl td {
  18.             border: 1px solid black;
  19.             padding: 5px;
  20.         }
  21.  
  22.         .BierDiv
  23.         {
  24.             color: black;
  25.             padding: 5px;
  26.             margin: 5px;
  27.             table-layout: fixed;
  28.  
  29.         }
  30.         .tblBier {
  31.             border-collapse: collapsed;
  32.  
  33.         }
  34.         .tblBier td {
  35.             border: 2px solid black;
  36.             padding: 5px;
  37.         }
  38.  
  39.  
  40.  
  41.     </style>
  42.     <script
  43.            src="https://code.jquery.com/jquery-3.4.1.min.js"
  44.            integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  45.            crossorigin="anonymous">
  46.  
  47.     </script>
  48.    
  49.     <script>
  50.        
  51.         var oFields = [
  52.             {veld: 'name', title: 'ID', zichtbaar: 'true'},
  53.             {veld: 'capital', title: 'Capital', zichtbaar: 'true'},
  54.             {veld: 'region', title: 'Region', zichtbaar: 'true'},
  55.             {veld: 'subregion', title: 'subregion', zichtbaar: 'true'},
  56.             {veld: 'population', title: 'population', zichtbaar: 'true'},
  57.             {veld: 'timezones', title: 'timezones', zichtbaar: 'true'},
  58.             ];
  59.         function Checkbox(index_cb, cb) {
  60.             console.log("checked");
  61.             oFields[index_cb].zichtbaar = cb.checked;
  62.             haalbier();                            
  63.         }
  64.  
  65.         function haalbier() {
  66.             console.log("Hallo");
  67.                        
  68.                         $.get("https://restcountries.eu/rest/v2/all", function(data, status){
  69.                             console.log(data);
  70.                            
  71.                             var html = "";
  72.                             $.each(oFields, function (i, obj) {
  73.                                 var chk="";
  74.                                
  75.                                 if(obj.zichtbaar){
  76.                                 chk="checked";
  77.                                 }
  78.                                 html += "<input type='checkbox' onclick='Checkbox("+i+", this)' "+chk+" />" +obj.title+"";
  79.                                
  80.                                 //else{ console.log("niet zichtbaar"); }
  81.                             });
  82.                             html += "<table class='tbl'>";
  83.                             html += "<tr>";
  84.                            
  85.                             $.each(oFields, function (i, obj) {
  86.                                 if(obj.zichtbaar){
  87.                                 html += "<th>" + obj.title + "</th>";
  88.                                 }
  89.                             });
  90.                             html += "</tr>";
  91.    
  92.                             $.each(data, function (i, biertje) {
  93.                                 html += "<tr>";
  94.                                 $.each(oFields, function (i, obj) {
  95.                                     if(obj.zichtbaar){
  96.                                     html += "<td> " + biertje[obj.veld] + "</td>";
  97.                                     }
  98.                                 });
  99.                                 html += "</tr>";
  100.                             });
  101.                             html += "</table>";
  102.                            
  103.                             $(".BierDiv").html(html);
  104.                         });
  105.         }
  106.  
  107.           $( document ).ready(function() {
  108.    
  109.    
  110.                
  111.                     $("#GetNames").click(function()
  112.                     {
  113.                         haalbier();
  114.                     });
  115.  
  116.  
  117.                 });
  118.  
  119.     </script>
  120. </head>
  121. <body>
  122.  
  123. <h1>Bier Tabel</h1>
  124. <div class="BierDiv"></div>
  125. <br> <br>
  126. <button id="GetNames">Tabel Ophalen</button>
  127.  
  128.  
  129. </body>
  130. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement