Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <style>
- #btn{
- width:100px;
- }
- #tbl{
- border:1px solid;
- width:500px;
- }
- .pomos{
- border:1px solid;
- font-weight: bold;
- text-align:center;
- }
- .temp{
- border:1px solid;
- }
- </style>
- </head>
- <body>
- <input id="btn" type="button" value="Get Data">
- <br>
- <select id="select">
- </select>
- <input id="chk" type="checkbox" checked>
- <br>
- <table id="tbl">
- </table>
- </body>
- <script type="text/javascript" src="jquery.js"></script>
- <script>
- var zname=0;
- function zemi(){
- zname=1;
- $.ajax({
- url:"myTutorials.txt",
- dataType:"json",
- success:function(data){
- $("#select").append("<option>display</option>");
- $("#select").append("<option>url</option>");
- $("#tbl").append("<tr> <td class='pomos'>display</td> <td class='pomos'>url</td>");
- $.each(data,function(index,item){
- var displej=item.display;
- var url=item.url;
- $("#tbl").append("<tr> <td class='temp'>"+displej+"</td> <td class='temp'>"+url+"</td>");
- });
- }
- });
- }
- $(document).ready(function(){
- $("#chk").prop("checked",true);
- $("#btn").click(function(){
- if(zname==0)
- zemi();
- });
- });
- $(function(){
- $("#chk").change(function(){
- var selected=$("select option:selected").val();
- if($(this).is(':checked'))
- {
- if(selected=="display")
- $("tr td:first-child").show();
- else if(selected=="url")
- $("tr td:nth-child(even)").show();
- }
- else
- {
- if(selected=="display")
- $("tr td:first-child").hide();
- else if(selected=="url")
- $("tr td:nth-child(even)").hide();
- }
- });
- $(function(){
- $("select").change(function(){
- var selected=$("select option:selected").val();
- if($("#chk").is(':checked'))
- {
- if(selected=="display")
- $("tr td:first-child").show();
- else if(selected=="url")
- $("tr td:nth-child(even)").show();
- }
- else
- {
- if(selected=="display")
- $("tr td:first-child").hide();
- else if(selected=="url")
- $("tr td:nth-child(even)").hide();
- }
- });
- });
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement