Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/04/2011, 20:22
Avatar de chicohot20
chicohot20
 
Fecha de Ingreso: mayo-2009
Mensajes: 388
Antigüedad: 15 años
Puntos: 43
Respuesta: Cambiar valor de variable php

Exactamente que quieres hacer con el tema de los botones?
Aca te dejo un ejemplo: http://cesarv.com/ajax/ pues si te sirve.


Los cosigo:

index.html
Código HTML:
Ver original
  1.     <head>
  2.         <title>Ejemplo</title>
  3.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  4.         <script>
  5.         $(function(){
  6.             $(".button").click(function(){
  7.                 $('#resultado').html("Cargando...");
  8.                 var valor=$(this).attr("rel");
  9.                 $.ajax({
  10.                   url: 'ajax.php',
  11.                   data: 'boton='+valor,
  12.                   type: 'POST',
  13.                   success: function(data){
  14.                     $('#resultado').html(data);
  15.                   }
  16.                 });
  17.             });
  18.         });
  19.     </script>
  20. </head>
  21.  <a href="#" rel="1" class="button">BOTON 1</a><br />
  22.  <a href="#" rel="2" class="button">BOTON 2</a><br />
  23.  <a href="#" rel="3" class="button">BOTON 3</a><br />
  24.  
  25.  <div id="resultado">ACA IMPRIMO</div>
  26.  
  27. </body>
  28. </html>


ajax.php
Código PHP:
Ver original
  1. <?
  2.      $boton=$_POST["boton"];          
  3.      echo "boton = $boton";
  4. ?>