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

AYUDA:Combo dependiente en heredoc

Estas en el tema de AYUDA:Combo dependiente en heredoc en el foro de Frameworks JS en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 05/06/2009, 14:37
Avatar de velma  
Fecha de Ingreso: marzo-2006
Mensajes: 94
Antigüedad: 18 años, 1 mes
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:
  #2 (permalink)  
Antiguo 05/06/2009, 14:51
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: AYUDA:Combo dependiente en heredoc

Perdona no entiendo lo que dices pero note un error en el segundo codigo

te falta declarar el value
<option value><?=$row['nombre']?></option>

debe ser así
<option value="<?=$row['nombre']?>"><?=$row['nombre']?></option>
  #3 (permalink)  
Antiguo 05/06/2009, 14:54
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: AYUDA:Combo dependiente en heredoc

No entiendo exactamente cuál es la relación con la sintaxis heredoc (si es que a eso te refieres):
http://www.php.net/manual/es/languag...syntax.heredoc
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #4 (permalink)  
Antiguo 06/06/2009, 13:41
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: AYUDA:Combo dependiente en heredoc

Tema trasladado desde PHP
  #5 (permalink)  
Antiguo 08/06/2009, 09:29
Avatar de velma  
Fecha de Ingreso: marzo-2006
Mensajes: 94
Antigüedad: 18 años, 1 mes
Puntos: 0
Respuesta: AYUDA:Combo dependiente en heredoc

ya quedo, gracias.
__________________
:cool: VELMA:si:
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 12:25.