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

Problema con Select de PAISES y CIUDADES

Estas en el tema de Problema con Select de PAISES y CIUDADES en el foro de Frameworks JS en Foros del Web. Gente, Tengo un problema con el siguiente script, cuando quiero imprimir en pantalla el VALOR de un SELECT cuyo contenido es generado a través de ...
  #1 (permalink)  
Antiguo 28/03/2009, 17:23
 
Fecha de Ingreso: mayo-2003
Mensajes: 312
Antigüedad: 21 años
Puntos: 2
Problema con Select de PAISES y CIUDADES

Gente,
Tengo un problema con el siguiente script, cuando quiero imprimir en pantalla el VALOR de un SELECT cuyo contenido es generado a través de AJAX.

Detallo...

Código:
Pagina: pagina1.php


<?
print_r($_POST); // print all the post-ed data. For testing

include("conex.php");


$sql="select * from Country";
$result = mysql_query($sql);


?>
<html>

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   <script src="ajax_req.js" type="text/javascript"></script>
</head>
<body>
<form method="post">

  


<select name="country" onchange="htmlData('city.php', 'ch='+this.value)" />
  <option value="#">-Select-</option>



<?
  while($row = mysql_fetch_array($result)) {

$paisant = $row['Name'];
$idpais = $row['Code'];


echo "<option value='" . $idpais . "'>" . $paisant . "</option>";

}

  ?>

</select>

<div id="txtResult"> <select name="cityList"><option></option></select> </div>
Ahora otra...

Código:
Página2: ajax_req.js


function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}

function stateChanged()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           document.getElementById("txtResult").innerHTML= xmlHttp.responseText;
   }
   else {
           //alert(xmlHttp.status);
   }
}

// Will populate data based on input
function htmlData(url, qStr)
{
   if (url.length==0)
   {
       document.getElementById("txtResult").innerHTML="";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}
Y la ultima...

Código:
<?
ini_set('display_errors', 1);
error_reporting(E_ALL);

include("conex.php");

$ex = $_GET['ch'];

$sql="select * from City where CountryCode='$ex' order by Name ASC";
         $result = mysql_query($sql);
?>

<select name="cityList">
<?
while($row = mysql_fetch_array($result)) {

$pro = $row['Name'];




echo "<option value='" . $pro . "'>" . $pro . "</option>"; 
}
echo "</select>";
?>

En la pagina 4, saco los resultados...
Por ejemplo:
$pais = $_POST['country'];
echo $pais;

Sin embargo, con la de las ciudades, la generada, NO ME FUNCIONA.

Alguien me daria una mano?!

Desde ya, mil gracias.
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 16:24.