Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/07/2014, 11:19
Avatar de alejo_ferguson
alejo_ferguson
 
Fecha de Ingreso: mayo-2014
Mensajes: 33
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: Actualizar checkbox PHP MYSQL

Te agradezco mucho tu tiempo y el codigo que me mandaste. No estoy tan familiarizado con JS asi que te pongo aca el codigo como lo escribi en mi pagina y me digas si tengo algun error pues al darle click al boton no hace nada! Gracias de antemano:


Código HTML:
<body>
<script type="text/javascript">
var checkbox = document.getElementById("foo"),
ajax = function(url){
	var xhr = window.XMLHttpRequest ? 
	new XMLHttpRequest() :
	new ActiveXObject("Microsoft.XMLHTTP") || 
	new ActiveXObject("Msxml2.XMLHTTP");

};	

	checkbox.addEventListener("click", function(){
		var estado = this.checked ? 1 : 0,
		id = this.getAttribute("data-id"),
		url = "ver_usuarios2.php?estado="+estado+"&id="+id;

		ajax(url);

	}, false);
</script>


</body>
</html> 
Y esta es la forma como la mando a llamar:


Código HTML:
<tr>
				  			<td>Usuarios Menu <input type="checkbox" id="foo" data-id="<?php echo '$id_usuario' ?>"></td>

				  		</tr>
				  	</table>
				  	<!-- <button class="btn btn-primary btn-block">Editar</button> -->
				  	<a class="btn" onClick="click()">Verificar</a>
				  </form>