Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script language="javascript" type="text/javascript" src="ajax.js"></script>
</head>
<body>
<table align="center">
<form>
<tr>
<td>Seleccionar entidad</td>
<td><select id="selEnt" name="selEnt" size="1" onchange="ajaxFunction()">
<option value="todo"<? if ($fE=="todo") echo "selected=\"selected\""; ?>> Toda la república</option>
<option value="01" <? if ($fE=="01") echo "selected=\"selected\""; ?> >A</option>
<option value="02" <? if ($fE=="02") echo "selected=\"selected\""; ?> >B</option>
<option value="03" <? if ($fE=="03") echo "selected=\"selected\""; ?> >Ba</option>
<option value="04" <? if ($fE=="04") echo "selected=\"selected\""; ?> >C</option>
<option value="05" <? if ($fE=="05") echo "selected=\"selected\""; ?> >Co</option>
<option value="06" <? if ($fE=="06") echo "selected=\"selected\""; ?> >Co</option>
<option value="07" <? if ($fE=="07") echo "selected=\"selected\""; ?> >Ch</option>
<option value="08" <? if ($fE=="08") echo "selected=\"selected\""; ?> >Chi</option>
<option value="09" <? if ($fE=="09") echo "selected=\"selected\""; ?> >Dl</option>
<option value="10" <? if ($fE=="10") echo "selected=\"selected\""; ?> >D</option>
<option value="11" <? if ($fE=="11") echo "selected=\"selected\""; ?> >G</option>
<option value="12" <? if ($fE=="12") echo "selected=\"selected\""; ?> >G</option>
<option value="13" <? if ($fE=="13") echo "selected=\"selected\""; ?> >H</option>
<option value="14" <? if ($fE=="14") echo "selected=\"selected\""; ?> >J</option>
<option value="15" <? if ($fE=="15") echo "selected=\"selected\""; ?> >M</option>
<option value="16" <? if ($fE=="16") echo "selected=\"selected\""; ?> >M</option>
<option value="17" <? if ($fE=="17") echo "selected=\"selected\""; ?> >M</option>
<option value="18" <? if ($fE=="18") echo "selected=\"selected\""; ?> >N</option>
<option value="19" <? if ($fE=="19") echo "selected=\"selected\""; ?> >N</option>
<option value="20" <? if ($fE=="20") echo "selected=\"selected\""; ?> >O</option>
<option value="21" <? if ($fE=="21") echo "selected=\"selected\""; ?> >P</option>
<option value="22" <? if ($fE=="22") echo "selected=\"selected\""; ?> >Q</option>
<option value="23" <? if ($fE=="23") echo "selected=\"selected\""; ?> >Q</option>
<option value="24" <? if ($fE=="24") echo "selected=\"selected\""; ?> >San L</option>
<option value="25" <? if ($fE=="25") echo "selected=\"selected\""; ?> >S</option>
<option value="26" <? if ($fE=="26") echo "selected=\"selected\""; ?> >S</option>
<option value="27" <? if ($fE=="27") echo "selected=\"selected\""; ?> >T</option>
<option value="28" <? if ($fE=="28") echo "selected=\"selected\""; ?> >T</option>
<option value="29" <? if ($fE=="29") echo "selected=\"selected\""; ?> >T</option>
<option value="30" <? if ($fE=="30") echo "selected=\"selected\""; ?>>V</option>
<option value="31" <? if ($fE=="31") echo "selected=\"selected\""; ?> >Y</option>
<option value="32" <? if ($fE=="32") echo "selected=\"selected\""; ?>>Z</option>
</select>
</td>
</tr>
<tr><td></td>
<td>
<div id='ajaxDiv'></div>
</td>
</tr>
<tr><td><input type="submit" /></td></tr>
</form>
</table>
</body>
</html>
Código PHP:
<?php
require_once("../comun/conexion.php"); // database connection
// Retrieve data from Query String
$make = $_GET['selEnt'];
//build query
$query = "SELECT municipio,nom_mun FROM inm_domicilio_carlos WHERE entidad = '$make' group by nom_mun";
$result = @mysql_query($query);
$rowEstados = mysql_fetch_array($result);
/////////////////////////////////////////////////
//esta parte funciona con firefox pero no con ie7
if($make == 'todo')
echo "<td style=\"display:none\"></td>";
//////////////
else
{
//Build Result String
$dropdown = "<select name=\"selMun\">";
$dropdown .= "<option value=\"\">Seleccione Municipio</option>";
// Insert a new row in the table for each person returned
do {
$dropdown .= "<option value=".$rowEstados['municipio'].">".$rowEstados['nom_mun']."</option>";
}while ($rowEstados = mysql_fetch_array($result));
$dropdown .= "</select>";
echo $dropdown;
}
?>