Advertisement
TheAkuma

Untitled

Dec 21st, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.16 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4.     <meta charset="UTF-8">
  5.     <title></title>
  6.     <style>
  7.     #btn{
  8.  
  9.         width:100px;
  10.     }
  11.     #tbl{
  12.         border:1px solid;
  13.         width:500px;
  14.     }
  15.     .pomos{
  16.  
  17.         border:1px solid;
  18.         font-weight: bold;
  19.         text-align:center;
  20.     }
  21.     .temp{
  22.         border:1px solid;
  23.     }
  24.  
  25.  
  26.     </style>
  27. </head>
  28. <body>
  29. <input id="btn" type="button" value="Get Data">
  30. <br>
  31. <select id="select">
  32.    
  33. </select>  
  34. <input id="chk" type="checkbox" checked>
  35. <br>
  36. <table id="tbl">
  37.     </table>
  38.  
  39.  
  40.  
  41. </body>
  42. <script type="text/javascript" src="jquery.js"></script>
  43. <script>
  44. var zname=0;
  45.     function zemi(){
  46.         zname=1;
  47.         $.ajax({
  48.             url:"myTutorials.txt",
  49.             dataType:"json",
  50.             success:function(data){
  51.                 $("#select").append("<option>display</option>");
  52.                 $("#select").append("<option>url</option>");
  53.                 $("#tbl").append("<tr>  <td class='pomos'>display</td> <td class='pomos'>url</td>");
  54.                 $.each(data,function(index,item){
  55.                     var displej=item.display;
  56.                     var url=item.url;
  57.                     $("#tbl").append("<tr>  <td class='temp'>"+displej+"</td> <td class='temp'>"+url+"</td>");
  58.  
  59.  
  60.                 });
  61.             }
  62.  
  63.         });
  64.  
  65.     }
  66.  
  67.     $(document).ready(function(){
  68.         $("#chk").prop("checked",true);
  69.         $("#btn").click(function(){
  70.             if(zname==0)
  71.             zemi();
  72.         });
  73.  
  74.     });
  75.  
  76.     $(function(){
  77.         $("#chk").change(function(){
  78.             var selected=$("select option:selected").val();
  79.             if($(this).is(':checked'))
  80.             {
  81.                 if(selected=="display")
  82.                 $("tr td:first-child").show();
  83.                 else if(selected=="url")
  84.                     $("tr td:nth-child(even)").show();
  85.             }
  86.             else
  87.             {
  88.                 if(selected=="display")
  89.                 $("tr td:first-child").hide();
  90.                 else if(selected=="url")
  91.                     $("tr td:nth-child(even)").hide();
  92.             }
  93.            
  94.            
  95.            
  96.            
  97.            
  98.  
  99.         });
  100.         $(function(){
  101.         $("select").change(function(){
  102.             var selected=$("select option:selected").val();
  103.             if($("#chk").is(':checked'))
  104.             {
  105.                 if(selected=="display")
  106.                 $("tr td:first-child").show();
  107.                 else if(selected=="url")
  108.                     $("tr td:nth-child(even)").show();
  109.             }
  110.             else
  111.             {
  112.                 if(selected=="display")
  113.                 $("tr td:first-child").hide();
  114.                 else if(selected=="url")
  115.                     $("tr td:nth-child(even)").hide();
  116.             }
  117.            
  118.  
  119.         });
  120.  
  121.     });
  122.     });
  123.  
  124. </script>
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement