Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/06/2009, 14:37
Avatar de velma
velma
 
Fecha de Ingreso: marzo-2006
Mensajes: 94
Antigüedad: 18 años, 2 meses
Puntos: 0
Exclamación AYUDA:Combo dependiente en heredoc

Hola que tal...

Podrian ayudarme con saber como puedo realizar un combo dependiente pero en heredoc, consegui un codigo para realizar uno de la siguiente manera


INDEX.PHP

Código PHP:
<html>
<head>
<title>Combos anidados</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script>
function getXMLHTTP() { //fuction to return the xml http object
        var xmlhttp=false;    
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {        
            try{            
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }
         return xmlhttp;
    }
        
    function getCity(strURL) {        
        var req = getXMLHTTP();
        if (req) {
            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                     //only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('vendedordiv').innerHTML=req.responseText;                        
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }                
            }            
            req.open("GET", strURL, true);
            req.send(null);
        }
    }
</script>


</head>
<body>
<form method="post" action="" name="form1">
<table width="60%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="150">Supervisor</td>
    <td  width="150">
    <select name="supervisor" onChange="getCity('findcity.php?nombre='+this.value)">
    <option value="">Selecciona Supervisor</option>
    
    
    <?php 

$link
mysql_connect("localhost","base"," "); 
mysql_select_db("general"$link) or die ("Cannot select database");
$result=mysql_query("SELECT  ID_SUP,CONCAT(paterno,' ',materno,' ', nombre) AS nombre FROM supervisores"); 
$error mysql_error($link);  // $link es la variable de conexión
                    
        
if ($error!=null)
        {
            print(
"Ocurr&oacute; El Siguiente Error:\n ".$error);
             exit;
        }
      if (
$row mysql_fetch_array($result)){ 
do { 
echo 
'<option value= "'.$row["ID_SUP"].'">'.$row["nombre"].'</option>'
} while (
$row mysql_fetch_array($result)); 
echo 
'</select>'
}
?>
</td>
  </tr>
  <tr style="">
    <td>vendedor</td>
    <td ><div id="vendedordiv"><select name="vendedor">
    <option>Select vendedor</option>
        </select></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>
FINDCITY.PHP


Código PHP:
<? $supervisor=$_REQUEST['nombre'];
$link mysql_connect('localhost''general'' '); 
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
mysql_select_db('general');
$query="SELECT ID_VEN, CONCAT(paterno,' ',materno,' ', nombre) AS nombre from vendedores where ID_SUP=$supervisor";
$result=mysql_query($query);

?>
<select name="vendedor">
<option>Select Vendedor</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value><?=$row['nombre']?></option>
<? ?>
</select>
Como podria añadir esto a mi heredoc, ya antes habia tratado de trabajar con javascript pero no funciono puesto que al parecer no lo reconoce.
__________________
:cool: VELMA:si: