Código PHP:
<html>
<head>
<title>
FAQ-1: Selects
</title>
<script language="JavaScript">
function addOpt(oCntrl, iPos, sTxt, sVal){
var selOpcion=new Option(sTxt, sVal);
eval(oCntrl.options[iPos]=selOpcion);
}
function cambia(oCntrl){
while (oCntrl.length) oCntrl.remove(0);
switch (document.frm.central.selectedIndex){
<?php
include("conexion.php");
$conexion = obtenerConexion();
$result1=mysql_query("select CONCAT(C4, '/ ',cSerial,'/',cRangoI,'/', cRangoF) AS Completo from tnumeracion ");
if ($row1 = mysql_fetch_array($result1,$conexion)){
echo '<select name= "central">';
do {
echo '<option value= "'.$row1["Completo"].'">'.$row1["Completo"].'</option>';
} while ($row1 = mysql_fetch_array($result1));
echo '</select>';
}
?>
break;
}
}
</script>
</head>
<body>
<form name="frm">
<table border="0">
<tr>
<td>
Central
</td>
<td>
<?php
$conexion = obtenerConexion();
$result=mysql_query("select CONCAT(C4, '/ ',CENTRAL,'/',NUMCPA) AS nombre from tmatrizcpa ORDER BY CENTRAL DESC");
if ($row = mysql_fetch_array($result,$conexion)){
echo '<select name= "central" onchange="cambia(document.frm.numeracion)">';
do {
echo '<option value= "'.$row["nombre"].'">'.$row["nombre"].'</option>';
} while ($row = mysql_fetch_array($result));
echo '</select>';
}
?>
</td>
<td>
</td>
<td>
Numeracion
</td>
<td>
<?php
$conexion = obtenerConexion();
$result1=mysql_query("select CONCAT(C4, '/',cSerial,'/',cRangoI,'/', cRangoF) AS Completo from tnumeracion");
if ($row1 = mysql_fetch_array($result1,$conexion)){
echo '<select name= "numeracion">';
do {
echo '<option value= "'.$row1["Completo"].'">'.$row1["Completo"].'</option>';
} while ($row1 = mysql_fetch_array($result1));
echo '</select>';
}
?>
</td>
</tr>
</table>
</form>
</body>
</html>