Guest User

Untitled

a guest
Nov 6th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  4. <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
  5. <style>
  6. * {
  7. box-sizing: border-box;
  8. }
  9.  
  10. body {
  11. background-color: #f1f1f1;
  12. }
  13.  
  14. #regForm {
  15. background-color: #ffffff;
  16. margin: 100px auto;
  17. font-family: Raleway;
  18. padding: 40px;
  19. width: 70%;
  20. min-width: 300px;
  21. }
  22.  
  23. h1 {
  24. text-align: center;
  25. }
  26.  
  27. input {
  28. padding: 10px;
  29. width: 100%;
  30. font-size: 17px;
  31. font-family: Raleway;
  32. border: 1px solid #aaaaaa;
  33. }
  34.  
  35. /* Mark input boxes that gets an error on validation: */
  36. input.invalid {
  37. background-color: #ffdddd;
  38. }
  39.  
  40. /* Hide all steps by default: */
  41. .tab {
  42. display: none;
  43. }
  44.  
  45. button {
  46. background-color: #4CAF50;
  47. color: #ffffff;
  48. border: none;
  49. padding: 10px 20px;
  50. font-size: 17px;
  51. font-family: Raleway;
  52. cursor: pointer;
  53. }
  54.  
  55. button:hover {
  56. opacity: 0.8;
  57. }
  58.  
  59. #prevBtn {
  60. background-color: #bbbbbb;
  61. }
  62.  
  63. /* Make circles that indicate the steps of the form: */
  64. .step {
  65. height: 15px;
  66. width: 15px;
  67. margin: 0 2px;
  68. background-color: #bbbbbb;
  69. border: none;
  70. border-radius: 50%;
  71. display: inline-block;
  72. opacity: 0.5;
  73. }
  74.  
  75. .step.active {
  76. opacity: 1;
  77. }
  78.  
  79. /* Mark the steps that are finished and valid: */
  80. .step.finish {
  81. background-color: #4CAF50;
  82. }
  83. </style>
  84. <body>
  85.  
  86. <form id="regForm" action="#">
  87. <h1>Wizualizacja:</h1>
  88. <!-- One "tab" for each step in the form: -->
  89. <div class="tab">Slajd 1:
  90. <p>Nazwa programu:<input oninput="this.className = ''" name="fname"></p>
  91. <p>Ilość śrubek:<input oninput="this.className = ''" name="lname"></p>
  92. <p><input type="file" name="file" oninput="this.className = ''" multiple=""></p>
  93. </div>
  94. <div class="tab">Slajd 2:
  95. <p><input oninput="this.className = ''" name="email"></p>
  96. <p><input oninput="this.className = ''" name="phone"></p>
  97. </div>
  98. <div class="tab">Slajd 3:
  99. <p><input oninput="this.className = ''" name="dd"></p>
  100. <p><input oninput="this.className = ''" name="nn"></p>
  101. <p><input oninput="this.className = ''" name="yyyy"></p>
  102. </div>
  103. <div class="tab">Slajd 4:
  104. <p><input oninput="this.className = ''" name="uname"></p>
  105. <p><input oninput="this.className = ''" name="pword" type="password"></p>
  106. </div>
  107. <div style="overflow:auto;">
  108. <div style="float:right;">
  109. <button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
  110. <button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
  111. </div>
  112. </div>
  113. <!-- Circles which indicates the steps of the form: -->
  114. <div style="text-align:center;margin-top:40px;">
  115. <span class="step"></span>
  116. <span class="step"></span>
  117. <span class="step"></span>
  118. <span class="step"></span>
  119. </div>
  120. </form>
  121.  
  122. <script>
  123. var currentTab = 0; // Current tab is set to be the first tab (0)
  124. showTab(currentTab); // Display the crurrent tab
  125.  
  126. function showTab(n) {
  127. // This function will display the specified tab of the form...
  128. var x = document.getElementsByClassName("tab");
  129. x[n].style.display = "block";
  130. //... and fix the Previous/Next buttons:
  131. if (n == 0) {
  132. document.getElementById("prevBtn").style.display = "none";
  133. } else {
  134. document.getElementById("prevBtn").style.display = "inline";
  135. }
  136. if (n == (x.length - 1)) {
  137. document.getElementById("nextBtn").innerHTML = "Submit";
  138. } else {
  139. document.getElementById("nextBtn").innerHTML = "Next";
  140. }
  141. //... and run a function that will display the correct step indicator:
  142. fixStepIndicator(n)
  143. }
  144.  
  145. function nextPrev(n) {
  146. // This function will figure out which tab to display
  147. var x = document.getElementsByClassName("tab");
  148. // Exit the function if any field in the current tab is invalid:
  149. if (n == 1 && !validateForm()) return false;
  150. // Hide the current tab:
  151. x[currentTab].style.display = "none";
  152. // Increase or decrease the current tab by 1:
  153. currentTab = currentTab + n;
  154. // if you have reached the end of the form...
  155. if (currentTab >= x.length) {
  156. // ... the form gets submitted:
  157. document.getElementById("regForm").submit();
  158. return false;
  159. }
  160. // Otherwise, display the correct tab:
  161. showTab(currentTab);
  162. }
  163.  
  164. function validateForm() {
  165. // This function deals with validation of the form fields
  166. var x, y, i, valid = true;
  167. x = document.getElementsByClassName("tab");
  168. y = x[currentTab].getElementsByTagName("input");
  169. // A loop that checks every input field in the current tab:
  170. for (i = 0; i < y.length; i++) {
  171. // If a field is empty...
  172. if (y[i].value == "") {
  173. // add an "invalid" class to the field:
  174. y[i].className += " invalid";
  175. // and set the current valid status to false
  176. valid = false;
  177. }
  178. }
  179. // If the valid status is true, mark the step as finished and valid:
  180. if (valid) {
  181. document.getElementsByClassName("step")[currentTab].className += " finish";
  182. }
  183. return valid; // return the valid status
  184. }
  185.  
  186. function fixStepIndicator(n) {
  187. // This function removes the "active" class of all steps...
  188. var i, x = document.getElementsByClassName("step");
  189. for (i = 0; i < x.length; i++) {
  190. x[i].className = x[i].className.replace(" active", "");
  191. }
  192. //... and adds the "active" class on the current step:
  193. x[n].className += " active";
  194. }
  195. </script>
  196.  
  197. </body>
  198. </html>
Advertisement
Add Comment
Please, Sign In to add comment