Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/04/2012, 20:13
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: Cargar variable de un submit

Ok llamar una función descuerdo al link que presiones


Codigo HTML

Código HTML:
Ver original
  1. <a href="#" onclick="enviar(2)">eliminar</a>
  2. <a href="#" onclick="enviar(1)">Agregar</a>
  3.  
  4. <script>   
  5.     function enviar(accion)
  6.     {
  7.  
  8.        
  9.         document.getElementById('accion').value = accion;      
  10.             document.getElementById('formcliente').submit();
  11.        
  12.        
  13.     }
  14.    
  15.  
  16.  
  17. <form  name="formcliente" id="formcliente" action="archivo.php" method="post">
  18. <input type="hidden" id="accion" name="accion"  />
  19. </form>

Codigo PHP

Código PHP:
Ver original
  1. if (isset($_POST['accion'])){
  2.                    
  3.                    
  4.                 switch($_POST['accion']){
  5.                
  6.                     case 1:
  7.                        
  8.                         echo "Agregando";
  9.                    
  10.                     break;
  11.                    
  12.                    
  13.                     case 2:
  14.                    
  15.                         echo "Actualizando";
  16.                        
  17.                     break;
  18.                    
  19.                    
  20.                 }  
  21.                    
  22.        
  23.         }


Ojo : esto es en base al post original, pueden existe otros metodos mas practicos para hacer lo que estas intentando hacer.

Saludos.