1er combobox.
Código PHP:
<td align="center" bgcolor="#33FF33">
<form name="guarda1" method="get">
<label>
<select name="depto" id="depto" onclick="guardar()"/>
<?php
$e="SELECT depto FROM empleados ORDER BY depto";
$f=mysql_query($e, $conectar);
while($g=mysql_fetch_array($f))
{$h=$g['depto'];
?>
<option value="<?php echo $h;?>" > <?php echo $h;?> </option >
<?php } ?>
</label>
</form>
</td>
2do combobox.
Código PHP:
<?php
$t=$_GET['depto'];
?>
<tr>
<td align="center" bgcolor="#999900">
<form name="guarda" method="post" action="">
<label>
<select name="resp" id="resp" />
<?php
$a="SELECT nombre FROM empleados where depto='$t' ORDER BY nombre";
$b=mysql_query($a, $conectar);
while($c=mysql_fetch_array($b))
{$d=$c['nombre'];
?>
<option value="<?php echo $d;?>"> <?php echo $d;?> </option>
<?php } ?>
</label>
</form>
</td>
Ademas tengo esta funcion para que de el valor del primer combobox.
Código PHP:
<script language="javascript">
function guardar()
{guarda1.action="pruebas.php";
guarda1.submit();
}
</script>
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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
session_start();
$Usuario=$_SESSION['login'];
include ("conection.php");
$conectar=Conectar();
?>
<body>
<table width="780" border="0" cellspacing="0">
<tr>
<td align="center" bgcolor="#33FF33">
<form name="guarda1" method="get">
<label>
<select name="depto" id="depto" onclick="guardar()"/>
<?php
$e="SELECT depto FROM empleados ORDER BY depto";
$f=mysql_query($e, $conectar);
while($g=mysql_fetch_array($f))
{$h=$g['depto'];
?>
<option value="<?php echo $h;?>" > <?php echo $h;?> </option >
<?php } ?>
</label>
</form>
</td>
</tr>
<?php
$t=$_GET['depto'];
?>
<tr>
<td align="center" bgcolor="#999900">
<form name="guarda" method="post" action="">
<label>
<select name="resp" id="resp" />
<?php
$a="SELECT nombre FROM empleados where depto='$t' ORDER BY nombre";
$b=mysql_query($a, $conectar);
while($c=mysql_fetch_array($b))
{$d=$c['nombre'];
?>
<option value="<?php echo $d;?>"> <?php echo $d;?> </option>
<?php } ?>
</label>
</form>
</td>
</tr>
</table>
</body>
<script language="javascript">
function guardar()
{guarda1.action="pruebas.php";
guarda1.submit();
}
</script>
</html>
Saludos.