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

Problema con el DOM, AJAX y <option>

Estas en el tema de Problema con el DOM, AJAX y <option> en el foro de Frameworks JS en Foros del Web. Estoy intentando leer el contenido de 2 select <option> que son traidos a través de ajax a la página. El problema viene cuando intento leer ...
  #1 (permalink)  
Antiguo 24/12/2011, 05:43
starlightphp
Invitado
 
Mensajes: n/a
Puntos:
Problema con el DOM, AJAX y <option>

Estoy intentando leer el contenido de 2 select <option> que son traidos a través de ajax a la página. El problema viene cuando intento leer el contenido de esos <option>. Copio el código:

Código del DOM:

Código HTML:
Ver original
  1. $('#Consultar3').live('click', function(){         
  2.            var Date0 = $('#combo0 option:selected').attr("value");
  3.            var Date1 = $('#combo1 option:selected').attr("value");
  4.            $("#Statistics_Primitiva").load("../ajax/Estadisticas.php",{Control_Var:2, Date0:Date0, Date1:Date1});
  5.      });

Código del Ajax Request

Código PHP:
Ver original
  1. $variable_conect = new Conection;
  2.     $variable_UIModules = new UIModules;
  3.     $variable_conect->Conect();
  4.     if ($_REQUEST['Control_Var'] == 1){
  5.     $result = $variable_UIModules->Crear();
  6.     }else if ($_REQUEST['Control_Var'] == 2){
  7.     $result = $variable_UIModules->Statistics($_REQUEST['Date1'],      $_REQUEST['Date1']);
  8.     }
  9.     echo $result;

y por último, estas son mis 2 funciones, la primera trae los <option> y la segunda supuéstamente tiene que tratar el contenido de esos option.

Código PHP:
Ver original
  1. static function Crear(){
  2.     $print="";
  3.     for ($i=0; $i<2; $i++){
  4.         $variable_Provider = new UIProvider;
  5.         $value = $variable_Provider->GetDate();
  6.         $print.='<select id=combo'.$i.'; style="width:110; height:25">';
  7.         while ($row=mysql_fetch_row($value)){
  8.             $print.='<option value='.$row[1].'>'.$row[0].'</option>\n';  
  9.         }
  10.         $print.="</select><br>";
  11.     }
  12.     $print.='Caja<input id="combo3"; type="text" value="1" style="width:150; height:25"><br>';
  13.     $print.='<input id="Consultar3" type="button" value="Consultar" style="width:110; height:25"><br>';
  14.     echo $print;
  15.     }
  16.     static function Statistics($Date1, $Date2){
  17.     $variable_Provider = new UIProvider;
  18.     $value = $variable_Provider->GetStatistics($Date1, $Date2);
  19.     $print='Caja<input type="text" value='.$value[0].' style="width:150; height:25"><br>';
  20.     echo $print;
  21.    }

Puntualizar que en la función Crear que se encuentra en el fichero php:
$print.='<option value='.$row[1].'>'.$row[0].'</option>\n';
$row es un array que contiene unas fechas. Como no quiero mostrarle al usuario la fecha en el formato de mysql, lo que he hecho ha sido guardar en "value" el valor de la base de datos real para no tener que tratar con el cuando el usuario seleccione. vamos para que vaya directo a la base de datos mientras que $row[0] está editado con la fecha en formato dd/mm/yyyy

No consigo leer el contenido de esos option cuando son traidos a mi formulario principal main. Alguna idea?

Última edición por starlightphp; 24/12/2011 a las 05:48

Etiquetas: <option>, ajax, dom
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:55.