Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Checkbox PHP con MySQL

Estas en el tema de Checkbox PHP con MySQL en el foro de Frameworks JS en Foros del Web. Checkbox PHP con MySQL checkbox marcado valor = 1 checkbox desmarcado valor = 0 Como le puedo enviar el valor de cada checkbox a la ...
  #1 (permalink)  
Antiguo 06/05/2010, 14:33
 
Fecha de Ingreso: marzo-2010
Mensajes: 432
Antigüedad: 14 años, 1 mes
Puntos: 11
Checkbox PHP con MySQL

Checkbox PHP con MySQL

checkbox marcado valor = 1
checkbox desmarcado valor = 0

Como le puedo enviar el valor de cada checkbox a la consulta con solo hacer onclick ?

index.html
Código HTML:
Ver original
  1. <form action="checkbox.php" method="post">
  2.  
  3. <input type="checkbox" name="check 1">opcion 1
  4. <input type="checkbox" name="check 2">opcion 2
  5. <input type="checkbox" name="check 3">opcion 3
  6. <input type="checkbox" name="check 4">opcion 4
  7. <input type="checkbox" name="check 5">opcion 5
  8. <input type="checkbox" name="check 6">opcion 6
  9. <input type="checkbox" name="check 7">opcion 7
  10. <input type="checkbox" name="check 8">opcion 8
  11. <input type="checkbox" name="check 9">opcion 9
  12. <input type="checkbox" name="check 10">opcion 10
  13. <input type="checkbox" name="check 11">opcion 11
  14. <input type="checkbox" name="check 12">opcion 12
  15. <input type="checkbox" name="check 13">opcion 13
  16. <input type="checkbox" name="check 14">opcion 14
  17. <input type="checkbox" name="check 15">opcion 15
  18. <input type="checkbox" name="check 16">opcion 16
  19. <input type="checkbox" name="check 17">opcion 17
  20. <input type="checkbox" name="check 18">opcion 18
  21. <input type="checkbox" name="check 19">opcion 19
  22. <input type="checkbox" name="check 20">opcion 20
  23. <input type="checkbox" name="check 21">opcion 21
  24. <input type="checkbox" name="check 22">opcion 22
  25. <input type="checkbox" name="check 23">opcion 23
  26. <input type="checkbox" name="check 24">opcion 24
  27. <input type="checkbox" name="check 25">opcion 25
  28. <input type="checkbox" name="check 26">opcion 26
  29. <input type="checkbox" name="check 27">opcion 27
  30. <input type="checkbox" name="check 28">opcion 28
  31. <input type="checkbox" name="check 29">opcion 29
  32. <input type="checkbox" name="check 30">opcion 30
  33.  
  34. </form>

checkbox.php
Código PHP:
Ver original
  1. $q = "UPDATE mitabla set estado= $check_estado".



Esto es lo que tengo.

Código PHP:
Ver original
  1. <?php
  2.  
  3. echo"
  4. <script language='javascript' type='text/javascript'>
  5. <!--
  6. // Get the HTTP Object
  7. function getHTTPObject(){
  8.     if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
  9.         else if (window.XMLHttpRequest) return new XMLHttpRequest();
  10.     else {
  11.         alert('Your browser does not support AJAX.');
  12.         return null;
  13.     }
  14. }
  15.  
  16. // Change the value of the outputText field
  17. function setOutput(){
  18.     if(httpObject.readyState == 4){
  19.         document.getElementById('outputText').value = httpObject.responseText;
  20.     }
  21. }
  22.  
  23. // Implement business logic
  24. function doWork(){
  25.     httpObject = getHTTPObject();
  26.     if (httpObject != null) {
  27.         httpObject.open('GET', 'checkbox.php?inputText='
  28.         +document.getElementById('inputText').checked == true, true);
  29.         httpObject.send(null);
  30.         httpObject.onreadystatechange = setOutput;
  31.     }
  32. }
  33. var httpObject = null;
  34. //-->
  35. </script>
  36. ";
  37.  
  38. echo"
  39. <form name='testForm'>
  40. <input type='checkbox' name='check 1' value='0' onclick='doWork();'  id='inputText'>opcion 1
  41.  
  42.  
  43. Output text: <input type='text' name='outputText' id='outputText' />
  44. </form>
  45. ";
  46.  
  47. ?>


checkbox.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. $valor = $_GET['inputText'];
  4. echo "$valor";
  5.  
  6. ?>
  #2 (permalink)  
Antiguo 06/05/2010, 15:25
 
Fecha de Ingreso: enero-2009
Mensajes: 455
Antigüedad: 15 años, 3 meses
Puntos: 11
Respuesta: Checkbox PHP con MySQL

que error te manda cuando lo ejecutas??

Etiquetas: ajax, checkbox, mysql, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:40.