Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. // Botão do login
  4.  
  5. $("#botao_login").click(function() {
  6.  
  7. $.ajax ({
  8.  
  9. type: "POST",
  10. url:'handle/login.php',
  11. data: { username : $("#username").val() , password : $("#password").val() },
  12.  
  13. success: function(result) {
  14. $('#result').html(result);
  15. }
  16.  
  17. });
  18.  
  19. });
  20.  
  21. // Botão do registo
  22.  
  23. $("#botao_registo").click(function() {
  24.  
  25. var nivel = $("#nivel :selected").attr('value');
  26.  
  27. $.ajax ({
  28.  
  29. type: "POST",
  30. url:'../handle/registo.php',
  31. data: { nivel : nivel , nome : $("#nome").val() , email : $("#email").val() , morada : $("#morada").val() , codpostal : $("#codpostal").val() , username : $("#input-username").val() , password : $("#input-password").val() },
  32.  
  33. success: function(result) {
  34. $('#result').html(result);
  35. }
  36.  
  37. });
  38.  
  39. });
  40.  
  41. // Se o nivel for aluno, entao não necessita dos campos do username e password
  42.  
  43. $("#nivel").change(function(){
  44.  
  45. var nivel = $("#nivel :selected").attr('value');
  46.  
  47. if (nivel != 4) {
  48.  
  49. $('#label-username').show();
  50. $('#input-username').show();
  51. $('#label-username').html('<label id="label-username" class="control-label">Nome de Utilizador</label>');
  52. $('#input-username').html('<input id="input-username" class="form-control" type="text" placeholder="Nome de Utilizador"><br>');
  53.  
  54. $('#label-password').show();
  55. $('#input-password').show();
  56. $('#label-password').html('<label id="label-password" class="control-label">Palavra-Passe</label>');
  57. $('#input-password').html('<input id="input-password" class="form-control" type="password" placeholder="Palavra-Passe"><br>');
  58.  
  59. } else {
  60.  
  61. $('#label-username').hide();
  62. $('#input-username').hide();
  63.  
  64. $('#label-password').hide();
  65. $('#input-password').hide();
  66.  
  67. }
  68.  
  69. });
  70.  
  71. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement