Advertisement
Guest User

Untitled

a guest
May 27th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html><head>
  3. <meta http-equiv="content-type" content="text/html; charset=UTE-8">
  4. <style>
  5. input {
  6. border: 2px solid #666;
  7. </style>
  8. <meta content="IE=11.0000" http-equiv="X-UA-Compatible">
  9.  
  10. <meta charset="utf-8">
  11. <title>Formularz</title>
  12. <script>
  13. function wyslij(){
  14.  
  15. if (document.getElementById("mezczyzna").checked == true) {
  16. plec = "mężczyzna";
  17. } else if (document.getElementById("kobieta").checked == true) {
  18. plec = "kobieta";
  19. } else {
  20. plec = false;
  21. }
  22. zaintersowania = new Array();
  23. if (document.getElementById("sport").checked == true) { zaintersowanie1 = "sport";
  24. } else { zaintersowanie1 = "";
  25. }
  26. if (document.getElementById("muzyka").checked == true) {
  27. zaintersowanie2 = "muzyka";
  28. } else { zaintersowanie2 = "";
  29. }
  30. if (document.getElementById("literatura").checked == true) {
  31. zaintersowanie3 = "literatura";
  32. } else { zaintersowanie3 = "";
  33. }
  34. if (document.getElementById("podroze").checked == true) {
  35. zaintersowanie4 = "podroze";
  36. } else { zaintersowanie4 = "";
  37. }
  38. if (document.getElementById("informatyka").checked == true) {
  39. zaintersowanie5 = "informatyka";
  40. } else { zaintersowanie5 = "";
  41. }
  42.  
  43. imie = document.getElementById("imie");
  44. nazwisko = document.getElementById("nazwisko");
  45. miejsce = document.getElementById("zamieszkanie");
  46. wiadomosc = document.getElementById("wiadomosc");
  47.  
  48.  
  49. waliduj();
  50. }
  51. function reset() {
  52. document.getElementById("imie").value = " "; document.getElementById("nazwisko").value = " "; document.getElementById("mezczyzna").checked = false; document.getElementById("kobieta").checked = false; document.getElementById("sport").checked = false; document.getElementById("muzyka").checked = false; document.getElementById("literatura").checked = false; document.getElementById("podroze").checked = false; document.getElementById("zamieszkanie").selectedIndex = 0; document.getElementById("wiadomosc").value = " ";
  53. }
  54.  
  55. function waliduj() {
  56.  
  57. var wszystkoOK = true;
  58. var errors = "Musisz uzupełnić następujące pola: <br>";
  59.  
  60. if(imie.value == "") {
  61. errors += "- Imie <br>";
  62. wszystkoOK = false;
  63. imie.style.borderColor = "red";
  64. }
  65.  
  66. if(nazwisko.value == "") {
  67. errors += "- Nazwisko <br>";
  68. wszystkoOK = false;
  69. nazwisko.style.borderColor = "red";
  70. }
  71.  
  72. if(miejsce.value == "") {
  73. errors += "- Zamieszkanie <br>";
  74. wszystkoOK = false;
  75. miejsce.style.borderColor = "red";
  76. }
  77.  
  78. if(plec == false) {
  79. errors += "- Płeć <br>";
  80. wszystkoOK = false;
  81. }
  82. if(miejsce.selectedIndex == 0) {
  83. errors += "- Miejsce zamieszkania <br>";
  84. wszystkoOK = false;
  85. miejsce.style.borderColor = "red";
  86. }
  87.  
  88. if(zaintersowanie1 == "" && zaintersowanie2 == "" && zaintersowanie3 == "" && zaintersowanie4 == "" && zaintersowanie == "") {
  89. errors += "- Przedmioty <br>";
  90. wszystkoOK = false;
  91. }
  92.  
  93. if(wiadomosc.value == "") {
  94. errors += "- Wiadomość <br>";
  95. wszystkoOK = false;
  96. wiadomosc.style.borderColor = "red";
  97. }
  98.  
  99. if(wszystkoOK != true) { document.getElementById("errors").innerHTML = errors;
  100. } else {
  101. document.write("Formularz uzupełniono pomyślnie:<br><hr><h2>Podsumowanie</h2><br><hr>");
  102. document.write("Imiona i nazwisko: " + imie.value + " " + nazwisko.value + "<br>");
  103. document.write("Płeć: " + plec + "<br>");
  104. document.write("Przedmioty: " + zaintersowania +
  105. "<br>");
  106. document.write("Klasa: " + miejsce.value+"<br>");
  107. document.write("Zainteresowania: " + wiadomosc.value + "<br>")} };
  108. </script>
  109.  
  110.  
  111. <meta name="GENERATOR" content="MSHTML 11.00.9600.18125"></head>
  112. <body>Imię:
  113. <input id="imie" type="text">
  114. <br> Nazwisko:
  115. <input id="nazwisko" type="text">
  116. <br>Płeć: Mężczyzna
  117. <input name="a1" id="mezczyzna" type="radio"> Kobieta
  118.  
  119. <input name="a1" id="kobieta" type="radio" value="kobieta"><br>Przedmioty:
  120. Biologia
  121. <input id="sport" type="checkbox"> Geografia
  122. <input id="muzyka" type="checkbox"> Historia
  123. <input id="literatura" type="checkbox"> Fizyka
  124. <input id="podroze" type="checkbox">Informatyka
  125. <input id="informatyka" type="checkbox">
  126. <br>Klasa:
  127. <select id="zamieszkanie">
  128. <option selected="selected">----------
  129. </option>
  130. <option>1 AI</option> <option>2 AI</option> <option>3 AI</option> <option>4 AI</option></select>
  131. <br>Zainteresowania:<br>
  132. <textarea id="wiadomosc"></textarea>
  133. <br> <input id="wyslij" onclick="wyslij()"
  134. type="button" value="Wyślij"> <div id="errors"></div>
  135. </body>
  136. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement