DamSi

Untitled

Dec 24th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <title>JSON</title>
  5.     <script type="text/javascript">
  6.         var json = {
  7.             files:
  8.             [
  9.              {
  10.                  display: "HTML Tutorial",
  11.                  url: "http://www.w3schools.com/html/default.asp"
  12.              },
  13.              {
  14.                  display: "CSS Tutorial",
  15.                  url: "http://www.w3schools.com/css/default.asp"
  16.              },
  17.              {
  18.                  display: "JavaScript Tutorial",
  19.                  url: "http://www.w3schools.com/js/default.asp"
  20.              },
  21.              {
  22.                  display: "jQuery Tutorial",
  23.                  url: "http://www.w3schools.com/jquery/default.asp"
  24.              },
  25.              {
  26.                  display: "JSON Tutorial",
  27.                  url: "http://www.w3schools.com/json/default.asp"
  28.              },
  29.              {
  30.                  display: "AJAX Tutorial",
  31.                  url: "http://www.w3schools.com/ajax/default.asp"
  32.              },
  33.              {
  34.                  display: "SQL Tutorial",
  35.                  url: "http://www.w3schools.com/sql/default.asp"
  36.              },
  37.               {
  38.                   display: "PHP Tutorial",
  39.                   url: "http://www.w3schools.com/php/default.asp"
  40.               },
  41.                {
  42.                    display: "XML Tutorial",
  43.                    url: "http://www.w3schools.com/xml/default.asp"
  44.                }
  45.             ]
  46.         }
  47.         function getData() {
  48.             var data = json.files;
  49.             var output = "<table border='1' id='table'><tr><td><b>display</td><td><b>url</b></td>";
  50.             for (var i = 0; i = data.length; i++) {
  51.                 var d = data[i];
  52.                 output += "<tr><td>" +
  53.                data[i].display + "</td><td>" +
  54.                data[i].url + "</td></tr>";
  55.             }
  56.             output += "</table>";
  57.             document.getElementById("tabela").innerHTML = out;
  58.         }
  59.    </script>
  60. </head>
  61. <body>
  62.     <div>
  63.         <button id="data" onclick="getData()">Get data</button><br />
  64.         <select id="rows">
  65.             <option id="display">display</option>
  66.             <option id="url">url</option>
  67.         </select>
  68.         <input type="checkbox" id="check" checked="checked" /><br /><br />
  69.         <div id="tabela"></div>
  70.     </div>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment