Ver Mensaje Individual
  #13 (permalink)  
Antiguo 26/11/2010, 13:49
Avatar de malakian
malakian
 
Fecha de Ingreso: septiembre-2010
Ubicación: $malakian->Colombia();
Mensajes: 469
Antigüedad: 13 años, 7 meses
Puntos: 45
Respuesta: Por cada onclic en un checkbox enviar dato a BD

bueno mira este ejemplo,no se si es el mejor...
Código Javascript:
Ver original
  1. //creas elobjeto "AJAX"
  2. var myAjax = ajax();
  3. function ajax() {
  4.    var ajax = null;
  5.    if (window.XMLHttpRequest) {
  6.       try {
  7.          ajax = new XMLHttpRequest();
  8.       }
  9.       catch(e) {}
  10.    }
  11.    else if (window.ActiveXObject) {
  12.       try {
  13.          ajax = new ActiveXObject("Msxm12.XMLHTTP");
  14.       }
  15.       catch (e){
  16.          try{
  17.             ajax = new ActiveXObject("Microsoft.XMLHTTP");
  18.          }
  19.          catch (e) {}
  20.       }
  21.    }
  22.    return ajax;
  23. }
  24. function request() {
  25.    myAjax.open("POST", "tuarchivo.php");//puedes enviar por GET tambien asi
  26.    //myAjax.open("GET", "tuarchivo.php?"+tucheckbox);
  27.   //si la quieres usar debes descomentar y comentar cada linea correspondiente
  28.    myAjax.onreadystatechange = result;
  29.    myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  30.    myAjax.send();
  31. }
  32. function result() {
  33.    if (myAjax.readyState == 4) {
  34.       var obtengo_valor = myAjax.responseText; //de ser necesario
  35.       //aca puedes tener instrucciones segun tu necesidad
  36.    }
  37. }

creas un archivo PHP como te dijero anteriormente y recojes los datos ya seapor $_POST o $_GET... y realizas tus querys
__________________
Guitar Loco, Desarrollador Web PHP
Sigueme: @jose1x