Advertisement
Guest User

Untitled

a guest
May 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. <!DOCTYPE html> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"› <style> input f border: 2px solid #666; </style> <meta content="IE=11.0000" http-equiv="X-UA-Compatible"›
  2. <meta charset="utf-8"› <title>Formularz</title> <script> // Deklarujemy funkcje wysykajaca dane function wyslij() f
  3. tablicy
  4. if (document.getElementById("mezczyzna").checked == true) f plec = "meZczyzna"; 1 else if (document.getElementById("kobieta").checked == true)
  5. plec = "kobieta"; 1 else if (document.getElementById("gender").checked == true) f plec = "gender"; 1 else f // Jesli nie wybrana ustawiamy na false plec = false;
  6. // Deklarujemy tablice zawierajaca zainteresowania zaintersowania = new Array();
  7. // Sprawdzamy zainteresowania i jeSli sa zaznaczona dodajemy do
  8. if (document.getElementById("sport").checked == true) { zaintersowaniel = "sport"; } else f zaintersowaniel = "";
  9. 1 if (document.getElementById("muzyka").checked == true) { zaintersowanie2 = "muzyka"; } else f zaintersowanie2 = "";
  10. 1 if (document.getElementById("literatura").checked == true) f zaintersowanie3 = "literatura"; 1 else f zaintersowanie3 = "";
  11. 1 if (document.getElementById("podroze").checked == true) f zaintersowanie4 = "podroze"; 1 else f zaintersowanie4 = "";
  12. // Przypisujemy elementy HTML do zmiennych imie = document.getElementById("imie"); drugieimie = document.getElementById("drugieimie"); nazwisko = document.getElementById("nazwisko"); miejsce = document.getElementById("zamieszkanie"); skad = document.getElementById("skad").value; wiadomosc = document.getElementById("wiadomosc");
  13.  
  14. // Czyscimy czerwone obramowania nieprawidlowo uzupelnionych
  15. imie.style.borderColor = "#343434"; nazwisko.style.borderColor = "#343434"; drugieimie.style.borderColor = "#343434"; miejsce.style.borderColor = "#343434"; wiadomosc.style.borderColor = "#343434";
  16. // Wywokujemy funkcje walidujaca podane wartogci waliduj();
  17. function reset() f document.getElementById("imie").value = " "; document.getElementById("drugieimie").value = " "; document.getElementById("nazwisko").value = " "; document.getElementById("mezczyzna").checked = false; document.getElementById("kobieta").checked = false; document.getElementById("gender").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("skad").selectedIndex = 0; document.getElementById("wiadomosc").value = " ";
  18. 1 function waliduj() f
  19. // Jegli to zmienna bedzie "false" dane nie przejda walidacji var wszystkoOK = true;
  20. // String zawierajacy errory var errors = "Musisz uzupeInie nastepujace pola: <br>";
  21. // Jegli pole imie bedzie puste do zmiennej errors dodajemy jej nazwe, ustawiamy wszystkoOK na false i kolorujemu obramowanie pola na czerwone... if(imie.value == "") f errors += "- Imie <br>"; wszystkoOK = false; imie.style.borderColor = "red";
  22. if(drugieimie.value == "") f errors += "- Drugie imie <br>"; wszystkoOK = false; drugieimie.style.borderColor = "red";
  23. if(nazwisko.value == "") f errors += "- Nazwisko <br>"; wszystkoOK = false; nazwisko.style.borderColor = "red";
  24. if(miejsce.value == "") f errors += "- Zamieszkanie <br>"; wszystkoOK = false;
  25. miejsce.style.borderColor = "red";
  26. if(plec == false) f
  27. errors += "- Plea <br>";
  28. wszystkoOK = false;
  29. // Jesli wybrany jest podstawowy index znadczy to ze uzytkownik
  30. nic nie wybral
  31. if(miejsce.selectedIndex == 0) f
  32. errors += "- Miejsce zamieszkania <br>";
  33. wszystkoOK = false;
  34. miejsce.style.borderColor = "red";
  35. // sprawdzamy czy sa wybrane zainteresowania
  36. if(zaintersowaniel == "" && zaintersowanie2 == "
  37. zaintersowanie3 == "" && zaintersowanie3 == "") f
  38. errors += "- Zainteresowanie <br>";
  39. wszystkoOK = false;
  40. if(wiadomosc.value == "") f
  41. errors += "- Wiadomoge <br>";
  42. wszystkoOK = false;
  43. wiadomosc.style.borderColor = "red";
  44. if(wszystkoOK != true) {
  45. document.getElementById("errors").innerHTML = errors;
  46. } else f
  47. // Wszystko OK! Wygwietlamy dane!
  48. document.write("Formularz uzupelniono
  49. pomyglnie:<br><hr><h2>Podsumowanie</h2><br><hr>");
  50. document.write("Imiona i nazwisko: " + imie.value + " " +
  51. drugieimie.value + imie.nazwisko + "<br>");
  52. document.write("PIee: " + plea + "<br>");
  53. document.write("Zainteresowania: " + zaintersowania +
  54. "<br>");
  55. document.write("Miejsce zamieszkania: " + miejsce.value
  56. "<br>");
  57. document.write("Wiadomose: " + wiadomosc.value + "<br>") ;
  58. </script>
  59. <meta name="GENERATOR" content="MSHTML 11.00.9600.18125"›
  60. </head>
  61. <body>Pierwsze imie:
  62. <input id="imie" type="text">
  63. <br>Drugie imie:
  64. <input id="drugieimie" type="text">
  65. <br> Nazwisko:
  66. <input id="nazwisko" type="text">
  67. <br>PIee: Me2czyzna
  68. <input name="al" id="mezczyzna" type="radio"> Kobieta
  69. <input name="al" id="kobieta" type="radio" value="kobieta"> Gender <input name="al" id="gender" type="radio" value="gender"› <br>Zaintersowania: <br>Sport <input id="sport" type="checkbox"› Muzyka <input id="muzyka" type="checkbox"› Literatura <input id="literatura" type="checkbox"› Podr62e <input id="podroze" type="checkbox"› <br>Miejsce zamieszkania: <select id="zamieszkanie"><option selected="selected"› </option> <option>Afryka</option> <option>Ameryka PaInocna</option> <option>Ameryka PoIudniowa</option> <option>Australia</option> <option>Azja</option> <option>Europa</option> </select> <br>Gdzie Pan/Pani o nas uskyszak(a): <select id="skad"><option selected="selected">W prasie</option> <option>W radiu</option> <option>W telewizji</option> <option>W internecie</option> <option>Od znajomych</option> </select> <br>Wiadomoge: <textarea id="wiadomosc"></textarea> <br> <input id="wyslij" onclick="wyslij()" type="button" value="Wyglij"> <input onclick="location.reload()" type="button" value="Wyczysc"› <input onclick="reset()" type="button" value="Resetuj"› <div id="errors"></div>
  70. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement