Advertisement
Guest User

Untitled

a guest
May 6th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Brian Foran | Monarchy</title>
  5. <style>
  6. #selName {
  7. vertical-align:top;
  8. }
  9.  
  10.  
  11. </style>
  12. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  13. <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  14. <link rel="stylesheet" href="/resources/demos/style.css">
  15. <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  16. <script>
  17.  
  18. $(document).ready(function() {
  19. var myResults;
  20. $.getJSON('monarchy.json', function (data) {
  21. JSON_Response = data; //JSON_Response declared globally
  22. //alert(JSON_Response.dogs[0].dogName);
  23.  
  24. //adapted from http://www.w3schools.com/jsref/met_select_add.asp
  25. var mySelect = document.getElementById("selName");
  26. for (i = 0; i < JSON_Response.Monarchy.length; i++) {
  27. var myOption = document.createElement("option");
  28. myOption.text = JSON_Response.Monarchy[i].monarchName;
  29. myOption.value = i;
  30. try {
  31. // for IE earlier than version 8
  32. mySelect.add(myOption, mySelect.options[null]);
  33. }
  34. catch (e) {
  35. mySelect.add(myOption, null);
  36. }
  37.  
  38. } //end for
  39.  
  40.  
  41. });
  42. $("#selName").change(function() {
  43. var curr = $("#selName").val();
  44. $("#divNameInfo").html(JSON_Response.Monarchy[curr].monarchName + "<br>Reign: " + JSON_Response.Monarchy[curr].monarchStartYear + " - " + JSON_Response.Monarchy[curr].monarchEndYear + "<br>" + JSON_Response.Monarchy[curr].monarchHouse)
  45. $("#imgMonarch").attr("src", JSON_Response.Monarchy[curr].monarchImage);
  46. });
  47.  
  48. $("#selHouse").change(function() {
  49. var curr = $("#selHouse").val();
  50. myResults = jQuery.grep(JSON_Response.Monarchy, function (a, i) {
  51. return a.monarchHouse.indexOf(curr) != -1;
  52. }
  53. /*
  54. $("#taHouseInfo").val("");
  55. var finalResults = "";
  56. for (var i = 0; i < myResults.length; i++) {
  57. finalResults += myResults[i].name + "\n";
  58. }
  59.  
  60. $("#taHouseInfo").val(finalResults);*/
  61. });
  62. });
  63. </script>
  64. <script>
  65. $(function() {
  66. $("#tabs").tabs();
  67. });
  68. </script>
  69. </head>
  70. <body>
  71. <div id="tabs">
  72. <ul>
  73. <li><a href="#tabs-1">Individual Monarchs</a></li>
  74. <li><a href="#tabs-2">Houses</a></li>
  75. <li><a href="#tabs-3">Time Line</a></li>
  76. </ul>
  77.  
  78. <div id="tabs-1">
  79. <select id="selName"></select>
  80.  
  81. <div id="divNameInfo">
  82.  
  83. </div>
  84. <img src="qe2.jpg" id="imgMonarch" />
  85. </div>
  86. <div id="tabs-2">
  87. <select id="selHouse">
  88. <option value="default">Select a House</option>
  89. <option value="House of Windsor">House of Windsor</option>
  90. <option value="House of Saxe-Coburg-Gotha">House of Saxe-Coburg-Gotha</option>
  91. <option value="House of Brunswick">House of Brunswick</option>
  92. <option value="House of Stuart">House of Stuart</option>
  93. <option value="House of Stuart (Restored)">House of Stuart (Restored)</option>
  94. <option value="House of Orange and Stuart">House of Orange and Stuart</option>
  95. <option value="House of Tudor">House of Tudor</option>
  96. <option value="The Commonwealth">The Commonwealth</option>
  97. </select>
  98. <div id="divHouseInfo"></div>
  99. <textarea id="taHouseInfo" cols="20" rows="10" disabled="disabled"></textarea>
  100. </div>
  101. <div id="tabs-3">
  102.  
  103.  
  104. </div>
  105. </div>
  106. </body>
  107.  
  108. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement