Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>JSON</title>
- <script type="text/javascript">
- var json = {
- files:
- [
- {
- display: "HTML Tutorial",
- url: "http://www.w3schools.com/html/default.asp"
- },
- {
- display: "CSS Tutorial",
- url: "http://www.w3schools.com/css/default.asp"
- },
- {
- display: "JavaScript Tutorial",
- url: "http://www.w3schools.com/js/default.asp"
- },
- {
- display: "jQuery Tutorial",
- url: "http://www.w3schools.com/jquery/default.asp"
- },
- {
- display: "JSON Tutorial",
- url: "http://www.w3schools.com/json/default.asp"
- },
- {
- display: "AJAX Tutorial",
- url: "http://www.w3schools.com/ajax/default.asp"
- },
- {
- display: "SQL Tutorial",
- url: "http://www.w3schools.com/sql/default.asp"
- },
- {
- display: "PHP Tutorial",
- url: "http://www.w3schools.com/php/default.asp"
- },
- {
- display: "XML Tutorial",
- url: "http://www.w3schools.com/xml/default.asp"
- }
- ]
- }
- function getData() {
- var data = json.files;
- var output = "<table border='1' id='table'><tr><td><b>display</td><td><b>url</b></td>";
- for (var i = 0; i = data.length; i++) {
- var d = data[i];
- output += "<tr><td>" +
- data[i].display + "</td><td>" +
- data[i].url + "</td></tr>";
- }
- output += "</table>";
- document.getElementById("tabela").innerHTML = out;
- }
- </script>
- </head>
- <body>
- <div>
- <button id="data" onclick="getData()">Get data</button><br />
- <select id="rows">
- <option id="display">display</option>
- <option id="url">url</option>
- </select>
- <input type="checkbox" id="check" checked="checked" /><br /><br />
- <div id="tabela"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment