Uncaught Typeerror: cadastro.fecha is not a Function at Htmldivelement.onclick

Asked

Viewed 543 times

1

I’m having a problem with a script to close a "Box".. follow the codes below:

register.php

<form name="cadastro" action="" method="post">
<input type="hidden" name="acao" value="cadastro_simples" />
<div class="matricula">
    <label>Matrícula</label>
    <input type="text" value="<?php echo $idd; ?>" readonly>
</div>
<div class="nome">
    <label>Nome Completo</label>
    <input type="text" name="nome" id="nome">
</div>
<div class="categoria">
    <label>Categoria</label>
    <select name="categoria" id="categoria">
        <option>Selecione a categoria</option>
        <option value="socio-efetivo">Sócio Efetivo</option>
        <option value="socio-contribuinte">Sócio Contribuinte</option>
    </select>
</div>
<div class="admissao">
    <label>Data de Admissão</label>
    <input type="date" name="admissao" id="admissao">
</div>
<div class="cadastrar" onClick="cadastro_simples();">CADASTRAR</div>
<div class="cancelar_cadastro" onclick="cadastro.fecharA();">CANCELAR</div>
</form>

script js.

var cadastro = {
associado: function(titulo, conteudo) {
    $('body').css({
        'margin': '0px',
        'padding': '0px'
    }).prepend('<div class="sombra_associado animated fadeIn"><div class="associado animated fadeInDown"><div class="topo"><div class="nome">SIGA<font style="font-size:10px;">V1.0</font></div><div class="titulo">' + titulo + '</div></div><div class="conteudo">' + conteudo + '</div></div></div>');
    $('.associado').fadeIn(200);
    $('.sombra_associado').fadeIn(200);
},
 fechar: function() {
    $('.associado').removeClass('animated fadeInDown').addClass('animated fadeOutUp');

    setTimeout(function() {
        $('.sombra_associado').removeClass('animated fadeIn').addClass('animated fadeOut');
        $('.sombra_associado').fadeOut(500);
        $('.associado').fadeOut(500);
        setTimeout(function() {
            $('.sombra_associado').remove();
        }, 500);

    }, 300);
}
}

What happens... when I click on a button in my index it opens a box to register an associate, but when I click to cancel the registration, instead of closing the box, it returns me the error "Uncaught Typeerror: cadastro.fecha is not a Function at Htmldivelement.onclick ", the same code but with different variables, I used for other similar functions on the site and all worked, only this causes problems..

1 answer

1

Try switching register. for register.close.

The error is in the name only, seeing that in script js. the register variable is an object and holds an attribute that is a Function called "close".

var cadastro = {fechar: function() {}}

Proceeding?

  • It continues the same error Thiago, the name would not make a difference because within the registration variable, the other functions of closing, for example, registration.closeC, registration.closeD

  • Is the error still there, or has it already found a solution? It is that you only pasted a part of the code, so I deduced that it was the lack of a closed, but see if before closing there is no "}" out of place.

  • All right Thiago

Browser other questions tagged

You are not signed in. Login or sign up in order to post.