Advertisement
Guest User

Untitled

a guest
Feb 25th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. <div id="seat_field">
  2. <select name="seats" id="seats" class="field" required>
  3. <option value="" disabled selected>select</option>
  4. <option value="0">None</option>
  5. <option value="1">1</option>
  6. <option value="2">2</option>
  7. </select>
  8. </div>
  9.  
  10. <?php
  11. $servername = "localhost";
  12. $username = "***";
  13. $password = "***";
  14. $dbname = "***";
  15.  
  16. $conn = new mysqli($servername, $username, $password, $dbname);
  17.  
  18. $query = mysqli_query($conn, "SELECT SUM(seats) AS total_seats FROM event");
  19.  
  20. $row = mysqli_fetch_assoc($query);
  21.  
  22. $total_seats = $row['total_seats'];
  23. $available_seats = 44-$total_seats;
  24.  
  25. echo "<div><div id='available_seats' class='seats'>$available_seats</div><div id='seats_remaining' class='seats'>&nbspseats remaining</div></div>";
  26. ?>
  27.  
  28. $(document).ready(function() {
  29. var available_seats = document.getElementById("available_seats").innerHTML;
  30.  
  31. if (available_seats == 0){
  32. $("#seats").hide();
  33. $("#seats").prop('required', false);
  34. $("#seat_field").prepend("<strong>Check to add your party to the bus waiting list</strong>&nbsp&nbsp<input type='checkbox' name='waitlist' /> ");
  35. };
  36. });
  37.  
  38. <form action="volunteer.php" method="post" name="volunteer_form" id="plumb_form">
  39. <input type="text" name="first_name" value="" class="field" id="first_name" required>
  40. <input type="text" name="last_name" value="" class="field" id="last_name" required>
  41. <input type="text" name="email" value="" class="field" id="email" required>
  42.  
  43. <div id="seat_field">
  44. <select name="seats" id="seats" class="field" required>
  45. <option value="" disabled selected>select</option>
  46. <option value="0">None</option>
  47. <option value="1">1</option>
  48. <option value="2">2</option>
  49. </select>
  50. </div>
  51.  
  52. <?php
  53. $servername = "localhost";
  54. $username = "***";
  55. $password = "***";
  56. $dbname = "***";
  57.  
  58. $conn = new mysqli($servername, $username, $password, $dbname);
  59.  
  60. $query = mysqli_query($conn, "SELECT SUM(seats) AS total_seats FROM event");
  61.  
  62. $row = mysqli_fetch_assoc($query);
  63.  
  64. $total_seats = $row['total_seats'];
  65. $available_seats = 44-$total_seats;
  66.  
  67. echo "<div><div id='available_seats' class='seats'>$available_seats</div><div id='seats_remaining' class='seats'>&nbspseats remaining</div></div>";
  68. ?>
  69.  
  70. <input type="submit" name="submit" value="Submit" id="submit"></p>
  71.  
  72. </form>
  73.  
  74. <script>
  75.  
  76. $(document).ready(function() {
  77. var available_seats = document.getElementById("available_seats").innerHTML;
  78.  
  79. //THIS IS THE PART THAT'S CAUSING ME TROUBLE...
  80. if (available_seats == 0){
  81. $("#seat").hide();
  82. $("#seats").prop('required', false);
  83. $("#seat_field").prepend("<strong>Check to add your party to the bus waiting list</strong>&nbsp&nbsp<input type='checkbox' name='waitlist' value='1' /> ");
  84. };
  85.  
  86.  
  87.  
  88. $("#plumb_form").submit(function() {
  89.  
  90. var first_name = document.forms["plumb_form"]["first_name"].value;
  91. var last_name = document.forms["plumb_form"]["last_name"].value;
  92. var email = document.forms["plumb_form"]["email"].value;
  93. var phone = document.forms["plumb_form"]["phone"].value;
  94. var number = document.forms["plumb_form"]["number"].value;
  95. var seats = document.forms["plumb_form"]["seats"].value;
  96.  
  97.  
  98. if(first_name == "" || last_name == "" || email == "" || phone == "" || number == "" || seats == ""){
  99. return false;
  100. }
  101.  
  102.  
  103. else if (seats > available_seats) {
  104. alert("There are not enough seats remaining for your party. Please reduce the number of seats needed or email Darren at dklein@nycaudubon.org to place your party on a waiting list.");
  105. return false;
  106. }
  107.  
  108. else{
  109. $("#submit").hide();
  110. //YOU CAN IGNORE THIS LAST LINE, JUST A LITTLE ANIMATION THING, NOT RELEVANT HERE
  111. $("#thing").append('<div id="submitting" class="buttonText animated flash">Submitting...</br><div class="againStop" id="stop">Please wait</div></div>');
  112. };
  113. });
  114. });
  115.  
  116. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement