Guest User

Untitled

a guest
Aug 28th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Hello Student</title>
  4. <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
  5. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  6. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
  7.  
  8. </head>
  9. <body>
  10. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  11. <table id="parentTable">
  12. <thead>
  13. <tr class="category">
  14. <th></th>
  15. <th>Name</th>
  16. <th>Email</th>
  17. <th>Phone</th>
  18. </tr>
  19. </thead>
  20.  
  21. <tbody id="parentTableBody">
  22. </tbody>
  23. </table>
  24.  
  25. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  26. <div class="modal-dialog" role="document">
  27. <div class="modal-content">
  28. <div class="modal-body">
  29. <h3>Info</h3>
  30. <div class="well well-sm overflow-auto">
  31. <table class="table table-striped table-hover table-condensed" id="schoolTable">
  32. <thead>
  33. <tr>
  34. <th/>
  35. <th>School</th>
  36. <th>Grade</th>
  37. <th>Job</th>
  38. <th>Martial</th>
  39. <th>Etc</th>
  40. </tr>
  41. </thead>
  42. <tbody id="schoolModalBody">
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. <div class="modal-footer">
  48. <button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53.  
  54. </body>
  55. </html>
  56.  
  57. $(document).ready(function() {
  58. var arr1 = generateItem();
  59. if (arr1) {
  60. var arr2 = [].concat(arr1);
  61. var tr;
  62. $.each(arr2, function(i, e) {
  63. tr = $('<tr>');
  64. tr.append("<td>" + "<button id='modalBtn' type='button' class='btn btn-info' data-toggle='modal' data-target='#myModal'>Info</button>" + "</td>");
  65. tr.append("<td>" + (e.Name || "") + "</td>");
  66. tr.append("<td>" + (e.Email || "") + "</td>");
  67. tr.append("<td>" + (e.Phone || "") + "</td>");
  68. $('#parentTableBody').append(tr);
  69.  
  70. populateSchoolInfo(e);
  71. });
  72.  
  73. }
  74. });
  75. function populateSchoolInfo(kid) {
  76. var tr;
  77. $.each(kid.Edu, function(j, v){
  78. tr = $('<tr>');
  79. tr.append("<td>" + (v.School || "") + "</td>");
  80. tr.append("<td>" + (v.Grade || "") + "</td>");
  81. tr.append("<td>" + (v.Job || "") + "</td>");
  82. tr.append("<td>" + (v.Martial || "") + "</td>");
  83. tr.append("<td>" + (v.ETC || "") + "</td>");
  84. $('#schoolModalBody').append(tr);
  85. });
  86. }
  87.  
  88. function generateItem() {
  89. var kids = [{
  90. Name: "Gina",
  91. Email: "gina@email.com",
  92. Phone: "211-456-1234",
  93. Edu:[{School: "college", Grade: "Freshmen", Job: "Student", Martial: "S", ETC: " "}]
  94. },
  95. {
  96. Name: "Mark",
  97. Email: "mark@email.com",
  98. Phone: "144-411-2312",
  99. Edu:[{School: "highschool", Grade: "senior", Job: "cashier", Martial: "S", ETC: "honors"}]
  100. },
  101. {
  102. Name: "Jake",
  103. Email: "jake@email.com",
  104. Phone: "333-211-1111",
  105. Edu:[{School: "highschool", Grade: "senior", Job: "cashier", Martial: "S", ETC: "honors"}]
  106. }
  107. ];
  108. return kids;
  109. }
Add Comment
Please, Sign In to add comment