Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/09/2015, 09:42
franjgg
 
Fecha de Ingreso: marzo-2007
Mensajes: 751
Antigüedad: 17 años, 1 mes
Puntos: 4
Respuesta: Por que no envia correctamente los radio?

Para aquel que esté buscando, esta es la solución:

Código Javascript:
Ver original
  1. function nuevoAjax(){
  2.     var xmlhttp=false;
  3.     try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  4.     } catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  5.     } catch (E) {xmlhttp = false;}}
  6.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  7.     xmlhttp = new XMLHttpRequest();}
  8.     return xmlhttp;
  9. }
  10.  
  11. function enviarFormulario(url, formid, divrespuesta){
  12.         var Formulario = document.getElementById(formid);
  13.         var longitudFormulario = Formulario.elements.length;
  14.         var cadenaFormulario="";
  15.         for (var i=0; i <= Formulario.elements.length-1;i++) {
  16.         if(Formulario.elements[i].type=="checkbox" || Formulario.elements[i].type=="radio"){
  17.             if(Formulario.elements[i].checked==true){cadenaFormulario += "&"+Formulario.elements[i].name+'='+encodeURIComponent(Formulario.elements[i].value);}
  18.         }else{cadenaFormulario += "&"+Formulario.elements[i].name+'='+encodeURIComponent(Formulario.elements[i].value);}
  19.         }
  20.     peticion=nuevoAjax();
  21.     peticion.open("POST", url, true);
  22.     peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  23.     peticion.send(cadenaFormulario);
  24.     peticion.onreadystatechange = function() {
  25.         if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
  26.             RESPUESTA=peticion.responseText;
  27.                 document.getElementById(divrespuesta).innerHTML =RESPUESTA;
  28.         }
  29.     if (peticion.readyState == 4 && peticion.status != 200){
  30.         document.getElementById(divrespuesta)="FALLA EN LA COMUNICACION... SI EL PROBLEMA CONTINUA, FAVOR DE REPORTARLO";
  31.     }
  32.     }
  33. }