JavaScript - AYUDA,DESHABILITAR UN BOTON SUBMIT A PARTIR DE UNA CONDICION

 
Vista:
Imágen de perfil de Leidy Johan Contreras

AYUDA,DESHABILITAR UN BOTON SUBMIT A PARTIR DE UNA CONDICION

Publicado por Leidy Johan Contreras (11 intervenciones) el 07/09/2016 15:45:03
Buenos dias:

Necesito Habilitar el boton agregar y desabilitar el boton consultar, si el usuario elije la funcion agregar usuario, pero ni siquiera consigo desabilitar un bendito boton sin condicion con java Script.

Llevo tiempo partiendome la cabeza y no veo el por que ni siquiera me deshabilita el boton con la funcion habilitar en JavaScript.

Adjunto el codigo, no se que esta mal, he visto tutoriales y no consigo ver el error.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
         <script type="text/javascript">
 
         function habilitar(){
 
             document.getElementById("actualizar").disabled=true;
 
         }
 
        </script>
    </head>
    <body >
 
        <div id="sesion">
 
         <div class="div_titulo">
 
            <h2>Elija una funcion</h2>
 
        </div>
 
            <form id="" action="SrvFunciones" method="post">
 
                <input id="agregar" name="agregar" class="cbp-mc-submit-grande" type="submit" value="Agregar" onkeyup="habilitar()">
 
                <input id="actualizar" name="actualizar" class="cbp-mc-submit-grande" type="submit" value="Actualizar">
 
                <input id="consultar" name="consultar" class="cbp-mc-submit-grande" type="submit" value="Consultar">
 
            </form>
 
          </div>
 
    </body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alain
Val: 26
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

AYUDA,DESHABILITAR UN BOTON SUBMIT A PARTIR DE UNA CONDICION

Publicado por Alain (8 intervenciones) el 07/09/2016 21:45:48
Hola, estás segura de que estás usando el evento correcto y los tags correctos de HTML? Es que onKeyUp lo veo más para campos de texto y lo estás intentando usar con botones. La función está bien. Yo probé con lo siguiente y funcionó, y lo que cambié fue el evento :). Tampoco es que este sea el evento correcto para lo que quieres, pero para que veas que la función está OK. Saludos y suerte!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script type="text/javascript">
 
        function habilitar() {
 
            document.getElementById("actualizar").disabled = true;
 
        }
 
</script>
</head>
<body>
    <div id="sesion">
 
<div class="div_titulo">
 
<h2>Elija una funcion</h2>
 
</div>
 
      <form id="" action="SrvFunciones" method="post">
 
        <input id="agregar" name="agregar" class="cbp-mc-submit-grande" type="submit" value="Agregar" onmousemove="habilitar()"/>
 
        <input id="actualizar" name="actualizar" class="cbp-mc-submit-grande" type="submit" value="Actualizar"/>
 
        <input id="consultar" name="consultar" class="cbp-mc-submit-grande" type="submit" value="Consultar"/>
      </form>
 
</div>
</body>
</html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar