Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/jcmouse/public_html/app/code/include/model/database/db.class.php on line 18

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/jcmouse/public_html/app/code/include/model/database/db.class.php on line 18

Deprecated: Function eregi_replace() is deprecated in /home/jcmouse/public_html/app/code/include/model/database/posts.php on line 322

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/jcmouse/public_html/app/code/include/model/database/db.class.php on line 18

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/jcmouse/public_html/app/code/include/model/database/db.class.php on line 18
Habilitar-deshabilitar controles con JQuery - Code Army!
APUNTES SCHOOL/UNIV | Hace 12 años          

Habilitar-deshabilitar controles con JQuery


Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/jcmouse/public_html/app/code/include/model/database/db.class.php on line 18

Para deshabilitar un control de un formulario con jQuery se utiliza el atributo disabled

  1. $('#cmdRegistrar').attr('disabled','-1')

Y para habilitar nuevamente este control, se debe remover el atributo DISABLED

  1. $('#cmdRegistrar').removeAttr('disabled')

Por ejemplo:

Tenenmos un boton en un formulario X, presionamos este boton y utilizando jquery para evitar que sea presionado dos veces, se lo deshabilita, se llevan a continuaciones las demas aciones, incluido el AJAX, y cuando se recibe una respuesta, se vuelve a habilitar el boton

  1. $("#BOTON").click(function() {
  2. //se deshabilita control
  3. $('#BOTON').attr('disabled','-1');
  4. /* instrucciones javascript*/
  5. $.ajax({
  6. type: 'POST',
  7. url: 'index.php',
  8. data: 'acciones.php?action=algo',
  9. success: function(data) {
  10. /* instrucciones javascript*/
  11. //se quita atributo DISABLED
  12. $('#BOTON').removeAttr('disabled');
  13. }
  14. });//fin ajax
  15. });

Tags
Fuentes de Información
  • El contenido del post es de mi autoría, y/o, es un recopilación de distintas fuentes.
Dar Puntos
Quitar Puntos
 
10 Puntos
score +10/-0
21859
Visitas
Curso básic
Apuntes School/Univ
Practica Jav
Apuntes School/Univ
Programacion
Apuntes School/Univ
Comentarios
Mouse
Querido Lider
 
 Bolivia
Pais
 
 9889
Puntos
 
 225
Posts
 
 6
Preguntas
 
 10
Respuestas
 
 Hombre
Sexo
X

Se parte de Code Army!

Esta acción es solo para usuarios registrados