Guest User

Untitled

a guest
Nov 8th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. var room = 1;
  2.  
  3. function ReviewForm() {
  4. room++;
  5. var objTo = document.getElementById('ReviewForm')
  6. var divtest = document.createElement("div");
  7. divtest.setAttribute("class", "form-group removeclass" + room);
  8. var rdiv = 'removeclass' + room;
  9. divtest.innerHTML =
  10. '<hr>' +
  11. '<h2>Student:</h2>' +
  12. '<select>' +
  13. //Instead of these three names, I need to use the DB's info go generate the text and values
  14. '<option value="Adam">Adam</option> ' +
  15. '<option value="Bob">Bob</option> ' +
  16. '<option value="Cat">Cat</option>' +
  17. '</select></h2>' +
  18. objTo.appendChild(divtest)
  19.  
  20. <?php
  21. $NumberOfStudents = "";
  22. // $NumberOfStudents=$_GET['SelectedStudents'];
  23.  
  24.  
  25. $hostname = "host";
  26. $username = "user";
  27. $password = "pass";
  28. $databaseName = "_db";
  29. $conn ;
  30.  
  31.  
  32. $connect = mysqli_connect($hostname, $username, $password, $databaseName);
  33. /*if ($conn->connect_error) {
  34. die("Connection failed: " . $conn->connect_error);
  35. } */
  36.  
  37. //BELOW IS THE QUERY FROM THE DB THAT I AM TRYING TO GET TO REPRINT EACH TIME THE FUNCTION IS CALLED
  38.  
  39. $query = "SELECT concat (FirstName,' ', LastName) as StudentNames FROM `Student`";
  40. $result = mysqli_query($connect, $query);
  41.  
  42. ?>
  43.  
  44. <body>
  45. <!-- Wrapper -->
  46. <div id="wrapper">
  47. <!-- Main -->
  48. <div id="main">
  49. <div class="inner">
  50. <!-- Content -->
  51. <section>
  52. <!-- Form -->
  53. <form method="post" action="#">
  54. <div class="row uniform">
  55. <!-- Break -->
  56. <div class="12u$">
  57. <div style="height:550px;border:1px solid #ccc;font:16px/26px Georgia, Garamond, Serif;overflow:auto;"><!-- container for reviews-->
  58. <div id="ReviewForm">
  59. <hr>
  60. <h2>
  61. Student:
  62. <select>
  63. <!-- It is hardcoded into the page here, which is fine, but I would rather it generate when the page is loaded, and then can
  64. be called again each time a new dropdown is needed. -->
  65. <?php while($row1 = mysqli_fetch_array($result)):;?>
  66. <option value="<?php echo $row1['StudentNames'];?>"><?php echo $row1['StudentNames'];?></option>
  67. <?php endwhile;?>
  68. </select>
  69. </h2>
  70.  
  71. </div>
  72. </div>
  73. </form>
  74. <input type="hidden" name="count" value="1" />
  75. <div class="control-group" id="fields">
  76. <label class="control-label" for="field1"></label>
  77. <div class="controls" id="profs">
  78. <form class="input-group-btn">
  79. <div>
  80. <!--Here is the button that calls the function for a new dropdown menu-->
  81. <button class="btn btn-success" type="button" onclick="ReviewForm();">Add another student</button>
  82. </div>
  83. </form>
  84. <br>
  85. <br>
  86. </div>
  87. </div>
  88. </section>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- Scripts -->
  93. <script src="assets/js/jquery.min.js"></script>
  94. <script src="assets/js/skel.min.js"></script>
  95. <script src="assets/js/util.js"></script>
  96. <!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
  97. <script src="assets/js/main.js"></script>
  98. </body>
Add Comment
Please, Sign In to add comment