Habsburg

Dio Kôda

Jun 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ///HTML/////
  2. <label>Spol</label>
  3. <select name = "spolSel" id = "spolSel">
  4. <option value = "0">Odaberite:</option>
  5. </select>
  6. ///HTML/////
  7. ////JS//////
  8. function dohvatiSpol() {
  9. $.get("registracija.php", {source: "spol"}, function(res) {
  10. res = JSON.parse(res);
  11. for(var i = 0; i < res.length; ++i) {
  12. var naz = res[i]["naziv"];
  13. var id = res[i]["id"];
  14. $('#spolSel').append("<option value = \"" + id + "\" >" + naz + "</option>");
  15. }
  16. });
  17. };
  18. ////JS//////
  19. ////PHP/////
  20. if($input == "spol") {
  21. $spolovi = array();
  22. $upit = "SELECT * FROM spolovi";
  23. $rez = $baza->selectDB($upit);
  24.  
  25. while($row = $rez->fetch_assoc()) {
  26. $spolovi[] = $row;
  27. }
  28. echo json_encode($spolovi, JSON_UNESCAPED_UNICODE);
  29. }
  30. ////PHP/////
Advertisement
Add Comment
Please, Sign In to add comment