Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var room = 1;
- function ReviewForm() {
- room++;
- var objTo = document.getElementById('ReviewForm')
- var divtest = document.createElement("div");
- divtest.setAttribute("class", "form-group removeclass" + room);
- var rdiv = 'removeclass' + room;
- divtest.innerHTML =
- '<hr>' +
- '<h2>Student:</h2>' +
- '<select>' +
- //Instead of these three names, I need to use the DB's info go generate the text and values
- '<option value="Adam">Adam</option> ' +
- '<option value="Bob">Bob</option> ' +
- '<option value="Cat">Cat</option>' +
- '</select></h2>' +
- objTo.appendChild(divtest)
- <?php
- $NumberOfStudents = "";
- // $NumberOfStudents=$_GET['SelectedStudents'];
- $hostname = "host";
- $username = "user";
- $password = "pass";
- $databaseName = "_db";
- $conn ;
- $connect = mysqli_connect($hostname, $username, $password, $databaseName);
- /*if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- } */
- //BELOW IS THE QUERY FROM THE DB THAT I AM TRYING TO GET TO REPRINT EACH TIME THE FUNCTION IS CALLED
- $query = "SELECT concat (FirstName,' ', LastName) as StudentNames FROM `Student`";
- $result = mysqli_query($connect, $query);
- ?>
- <body>
- <!-- Wrapper -->
- <div id="wrapper">
- <!-- Main -->
- <div id="main">
- <div class="inner">
- <!-- Content -->
- <section>
- <!-- Form -->
- <form method="post" action="#">
- <div class="row uniform">
- <!-- Break -->
- <div class="12u$">
- <div style="height:550px;border:1px solid #ccc;font:16px/26px Georgia, Garamond, Serif;overflow:auto;"><!-- container for reviews-->
- <div id="ReviewForm">
- <hr>
- <h2>
- Student:
- <select>
- <!-- It is hardcoded into the page here, which is fine, but I would rather it generate when the page is loaded, and then can
- be called again each time a new dropdown is needed. -->
- <?php while($row1 = mysqli_fetch_array($result)):;?>
- <option value="<?php echo $row1['StudentNames'];?>"><?php echo $row1['StudentNames'];?></option>
- <?php endwhile;?>
- </select>
- </h2>
- </div>
- </div>
- </form>
- <input type="hidden" name="count" value="1" />
- <div class="control-group" id="fields">
- <label class="control-label" for="field1"></label>
- <div class="controls" id="profs">
- <form class="input-group-btn">
- <div>
- <!--Here is the button that calls the function for a new dropdown menu-->
- <button class="btn btn-success" type="button" onclick="ReviewForm();">Add another student</button>
- </div>
- </form>
- <br>
- <br>
- </div>
- </div>
- </section>
- </div>
- </div>
- </div>
- <!-- Scripts -->
- <script src="assets/js/jquery.min.js"></script>
- <script src="assets/js/skel.min.js"></script>
- <script src="assets/js/util.js"></script>
- <!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
- <script src="assets/js/main.js"></script>
- </body>
Add Comment
Please, Sign In to add comment