Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- // Botão do login
- $("#botao_login").click(function() {
- $.ajax ({
- type: "POST",
- url:'handle/login.php',
- data: { username : $("#username").val() , password : $("#password").val() },
- success: function(result) {
- $('#result').html(result);
- }
- });
- });
- // Botão do registo
- $("#botao_registo").click(function() {
- var nivel = $("#nivel :selected").attr('value');
- $.ajax ({
- type: "POST",
- url:'../handle/registo.php',
- data: { nivel : nivel , nome : $("#nome").val() , email : $("#email").val() , morada : $("#morada").val() , codpostal : $("#codpostal").val() , username : $("#input-username").val() , password : $("#input-password").val() },
- success: function(result) {
- $('#result').html(result);
- }
- });
- });
- // Se o nivel for aluno, entao não necessita dos campos do username e password
- $("#nivel").change(function(){
- var nivel = $("#nivel :selected").attr('value');
- if (nivel != 4) {
- $('#label-username').show();
- $('#input-username').show();
- $('#label-username').html('<label id="label-username" class="control-label">Nome de Utilizador</label>');
- $('#input-username').html('<input id="input-username" class="form-control" type="text" placeholder="Nome de Utilizador"><br>');
- $('#label-password').show();
- $('#input-password').show();
- $('#label-password').html('<label id="label-password" class="control-label">Palavra-Passe</label>');
- $('#input-password').html('<input id="input-password" class="form-control" type="password" placeholder="Palavra-Passe"><br>');
- } else {
- $('#label-username').hide();
- $('#input-username').hide();
- $('#label-password').hide();
- $('#input-password').hide();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement