Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/02/2014, 09:35
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Enviar formulario con evento onblur

Ok, pero el código no funciona:

Código Javascript:
Ver original
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
  5. <title>mi bug</title>
  6. </head>
  7. <script type="text/javascript" >
  8. $("#formulario").submit(function(e){
  9.     e.preventDefault();
  10.     $.ajax({
  11.         url: $(this).prop("action"),
  12.         data: $(this).serialize(),
  13.         success: function(response){
  14.             $("#contenido").val(response);
  15.         }
  16.     });
  17. });
  18.    $("#salida").blur(function(){
  19.     $("#formulario").trigger("submit");
  20. });
  21. </script>
  22. <body>
  23. <form id = "formulario" action = "ins1_avisos.php">
  24.   <table width="79%">
  25.             <tr>
  26.               <th scope="col" width="57">Teléfonos</th>
  27. <th scope="col" width="52"><input name="telefonos" id="telefonos"  type="text" size="9" maxlength="9"/></th>
  28.  
  29.              <th scope="col" width="46">Nombre</th>
  30.     <th scope="col" width="88"><input name="name" id="name" type="text" size="35"/>
  31.               </th>
  32.               <th scope="col" width="46">Apellidos</th>
  33.   <th scope="col" width="403"><input name="apellidos" id="apellidos" type="text" size="20" /></th>
  34.  
  35.     <th scope="col"><textarea id = "salida"></textarea></th>
  36.             </tr>
  37.            
  38.            
  39. </table>
  40. <input type="hidden" name="MM_insert" value="form1" />
  41.  
  42. </form>
  43. <div id="contenido"></div>
  44. </body>
  45. </html>


Y así ?

Código Javascript:
Ver original
  1. <script type="text/javascript" >
  2. $(document).ready(function(){
  3.     //insertando input por Jquery
  4.  
  5.     $('textarea').live('blur', function() {            
  6.              $("#formulario").trigger("submit");
  7.     });
  8.    
  9.    
  10.    
  11. })      
  12. </script>

Última edición por satjaen; 18/02/2014 a las 09:50