Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/10/2014, 15:37
omar_ga
 
Fecha de Ingreso: julio-2013
Ubicación: Guerrero
Mensajes: 5
Antigüedad: 10 años, 9 meses
Puntos: 0
Pregunta Como hago para, recibir un arreglo en la funcion Javascript?

La funcion es ChecaOpc(), recibe datos, solo si no es arreglo.

Pero lo que necesito es que reciba la informacion en arreglo en la funcion , para asi comprobar si se selecciona alguna opcion.

Pienso que el error esta en pregunta.length y pregunta[i].checked, pero no se como resolverlo. !Alguna idea porfavor¡

Código PHP:
echo "<script>
        function ChecaOpc(){
            var i, ninguna;
            for (i=0; i<document.form1.pregunta.length; i++){
               if (document.form1.pregunta[i].checked){
                    document.form1.submit();                    
                    ninguna=false;
                    break;                     
                }else { ninguna=true;}
            }if (ninguna) { 
                alert (\"Elige al menos una opcion\"); 
            }                  
        } 
    </script>"
;

$result2 mysql_query("select *From pregunta where idpregunta='$row->idpregunta'");
    echo 
"<form name=\"form1\" method=\"post\"  action=\"".$_SERVER['PHP_SELF']."\" >";
    while(
$row2 mysql_fetch_object($result2)){
        
//echo $row2 -> idreactivo; 
            
echo "<div  style=\"font-weight:bold;\">".$row2 -> idreactivo.".</span> ".nl2br($row2 -> reactivo)."<br/><br/>\n </div>";
            echo 
"<div style=\"padding:10px; font-size:14px;\">
                  
                  <td><input type=\"radio\" name=\"pregunta[$row2->idreactivo]\" value=\"A\">INSUFICIENTE</td>
                  <td><input type=\"radio\" name=\"pregunta[$row2->idreactivo]\" value=\"B\">REGULAR</td>
                  
                  </div>"
;  
                  echo 
"<br/>";       
    }
            echo 
"<input type=\"submit\" name=\"Submit Answers\"  value=\"Aceptar\"   value=Aceptar onClick=\"ChecaOpc();\>
                  <input type=\"reset\" name=\"reset\" value=\"Limpiar\"> "
;    
            echo 
"</form> "