Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/01/2009, 21:35
Avatar de Superlinux
Superlinux
 
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 18 años, 7 meses
Puntos: 1
Pregunta que pasa con los select

Hola amigos del web ... necesito .. usar estos dos select ..

Especilidad carga las Subespecilidad y Pais carga las cidades .. todo funciona bien cuando selecciono uno de ellos sea Especilidad o Pais. pero al intentar selecionar Pais despues de haber seleccionado Especilidad .. recarga y queda sin seleciono los campos...

Código PHP:
<?php
//Archivo de conexion
require("connect.php");

// ______________CREACION DE LA SESION POR PRIMERA VEZ ___________________________________________

// Si existe identificador actualizamos la informacion.
     
if ($_GET['id']){
        
$subesp $sql->seleccionar"pais_especialista""*""idPaisEspec =".$_GET['id']); 
        
$update 1;

      }
//Fin del if    

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script    language="javascript">

function direccionar1(url,valor) 

    window.open(url + valor,"_self"); 
}

function direccionar2(url1,valor1) 

    window.open(url1 + valor1,"_self"); 
}
</script>

</head>
</html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>

<body>
<?php 

if($update)
{
   
$url "add_paisespecialista1.php?&id=".$_GET[id]."&idesp=";
}
else
{
   
$url "add_paisespecialista1.php?&idesp=";
}
//Fin del if

///////////////////////////////////////////////////////////////

if($update2)
{
   
$url1 "add_paisespecialista1.php?&id=".$_GET[id]."&idpais=";
}
else
{
   
$url1 "add_paisespecialista1.php?&idpais=";
}
//Fin del if

?>
<form  name="form" method="post" action="add_paisespecialista_script.php" enctype="multipart/form-data"  >

<input name="type" type="hidden" value="<?php echo $_GET[type?>" />
<input name="id" type="hidden" value="<?php echo $_GET[id?>" />
<input name="action" type="hidden" value="" />

<input name="setimage" type="hidden" value="false" />
  <table width="93%" border="0" align="center">
    
    <tr> 
      <td width="24%"  class="td_cyan" scope="row"><div align="right"><strong>Especilidad</strong></div></td>
      <td width="36%" bgcolor="#EBEBF5"><div align="left"> 
          <select name="idespecialidad" class="input_white" id="idespecialidad"  onchange="direccionar1('<?php echo $url ?>',this.options[selectedIndex].value)" >
            <option value="none">Select...</option>
            <?php
            $especialidades 
$sql->seleccionarLibre"SELECT * FROM especialidad ORDER BY nombre"); 
            
            if(
$especialidades)
            {
                foreach(
$especialidades as $esp)
                {
                 
$ID$esp["idEspecialidad"];
                
                  if (
$esp)// Actualizacion del producto
                  
{       
                        
//if($id_esp)// Si el usuario cambia la categoria
                        
if($_GET['idesp'])// Si el usuario cambia la categoria
                        
{
                             
//$temp_id = $id_esp;
                             
$temp_id $_GET['idesp'];
                             
$refresh=1;
                        }
                        else 
// Si no, la categoria la obtiene de la base de datos
                        
{
                             
//$temp_id = $subespecialidad_ciudad['idEspecialidad'];
                             
$temp_id $especialista['idEspecialidad'];
                        }
//Fin del else
                  
}//Fin del if
                  //elseif($id_esp)//  Nuevo registro de producto
                  
elseif($_GET['idesp'])//  Nuevo registro de producto
                  
{
                    
//$temp_id = $id_esp;
                    
$temp_id $_GET['idesp'];
                    
$refresh=1;    
                  }
//Fin del if
                
                  
if($ID == $temp_id )
                    {
                    
?>
                        <option value="<?php echo $ID ?>"  selected="selected" > <?php echo $esp["nombre"];  ?></option>
                        <?php
                            
}
                            else
                            {
                            
?>
                        <option value="<?php echo $ID ?>" > <?php echo $esp["nombre"];  ?></option>
                        <?php
                     
}//Fin del else
                
}// Fin foreach 
            
}// Fin del if
          
?>
          </select>
        </div></td>
    </tr>
    <tr> 
      <td  class="td_cyan" scope="row"><div align="right"><strong>Subespecilidad</strong></div></td>
      <td bgcolor="#EBEBF5"><div align="left"><span class="textonormal"> 
          <select name="idsubesp" class="input_white" id="idsubesp" >
            <option value="none">Select...</option>
            <?php 
       
       
//-------SUBCATEGORIES______________________________________________________
 
          
if ($refresh==|| $update==1)//Si hay un evento de actualizar o recargar
           
{
            echo 
"recargarrrr";
            if(
$update && !$refresh)// Si la subcategoria es para actualizar
            
{
              
//echo $where="WHERE idEspecialidad=".$id_subesp;
              
echo $where="WHERE idEspecialidad=".$especialista['idEspecialidad'];
            }
            if(
$refresh && !$update)// Si la subcategoria se genera de recarga de formulario
            
{
              
//echo $where="WHERE idEspecialidad=".$id_subesp;
              
echo $where="WHERE idEspecialidad=".$_GET['idesp'];
            }
            if(
$refresh && $update)// Si la subcategoria es para actualizar y se ha recargado
            
{
             
//echo $where="WHERE idEspecialidad=".$id_subesp;
             
echo $where="WHERE idEspecialidad=".$_GET['idesp'];
            }
//Fin del if

            //$subesps  = $sql->seleccionarLibre( "SELECT * FROM subespecialidad where idSubesp=".$id_subesp." ORDER BY nombre"); 
             
$subesps  $sql->seleccionarLibre"SELECT * FROM subespecialidad ".$where." ORDER BY nombre"); 
            
             if(
$subesps)
             { 
                  foreach(
$subesps as $subesp)
                   {
                     
$ID$subesp["idSubesp"];
                     
$name $subesp["nombre"];
                     
                      
//if($update==1 && ($ID == $id_subesp) )
                      
if($update==&& ($ID == $especialista['idSubespecialidad']) )
                       {
                        
?>
                        <option value="<?php echo $ID ?>" selected="selected"><?php echo $name ?></option>
                        <?php
                       
}
                       else
                       {
                        
?>
                        <option value="<?php echo $ID ?>"><?php echo $name  ?></option>
                        <?php                       
                       
}
                   } 
              }
        }
        
//------- end  SUBCATEGORIES______________________________________________________
        
?>
          </select>
          </span></div></td>
    </tr>
    <tr> 
      <td  class="td_cyan" scope="row"><div align="right"><strong>Pais</strong></div></td>
      <td bgcolor="#EBEBF5"><select name="idPais" class="input_white" id="idPais"  onchange="direccionar2('<?php echo $url1 ?>',this.options[selectedIndex].value)" >
          <option value="idPais">Select...</option>
          <?php
            $paises 
$sql->seleccionarLibre"SELECT * FROM pais ORDER BY nombre"); 
            
            if(
$paises)
            {
                foreach(
$paises as $pai)
                {
                 
$ID2$pai["idPais"];
                
                  if (
$pai)// Actualizacion del producto
                  
{       
                        if(
$_GET['idpais'])// Si el usuario cambia la categoria
                        
{
                             
$temp_id2 $_GET['idpais'];
                             
$refresh2=1;
                        }
                        else 
// Si no, la categoria la obtiene de la base de datos
                        
{
                             
$temp_id2 $ciudad['idPais'];
                        }
//Fin del else
                  
}//Fin del if
                  
                  
elseif($_GET['idpais'])//  Nuevo registro de producto
                  
{
                    
$temp_id2 $_GET['idpais'];
                    
$refresh2=1;    
                  }
//Fin del if
                
                  
if($ID2 == $temp_id2 )
                    {
                    
?>
                      <option value="<?php echo $ID2 ?>"  selected="selected" > <?php echo $pai["nombre"];  ?></option>
                      <?php
                            
}
                            else
                            {
                            
?>
                      <option value="<?php echo $ID2 ?>" > <?php echo $pai["nombre"];  ?></option>
                      <?php
                     
}//Fin del else
                
}// Fin foreach 
            
}// Fin del if
          
?>
        </select></td>
    </tr>
    <tr> 
      <td  class="td_cyan" scope="row"><div align="right"><strong>Ciudad</strong></div></td>
      <td bgcolor="#EBEBF5"><div align="left"><span class="textonormal">
          <select name="idCiudad" class="input_white" id="idCiudad" >
            <option value="idCiudad">Select...</option>
            <?php 
       
           
//-------SUBCATEGORIES______________________________________________________
 
          
if ($refresh2==|| $update2==1)//Si hay un evento de actualizar o recargar
           
{
            echo 
"recargarrrr";
            if(
$update2 && !$refresh2)// Si la subcategoria es para actualizar
            
{
              echo 
$where="WHERE idPais=".$ciudad['idPais'];
            }
            if(
$refresh2 && !$update2)// Si la subcategoria se genera de recarga de formulario
            
{
              echo 
$where="WHERE idPais=".$_GET['idpais'];
            }
            if(
$refresh2 && $update2)// Si la subcategoria es para actualizar y se ha recargado
            
{
             echo 
$where="WHERE idPais=".$_GET['idpais'];
            }
//Fin del if

             
$ciudades  $sql->seleccionarLibre"SELECT * FROM ciudad ".$where." ORDER BY nombre"); 
            
             if(
$ciudades)
             { 
                  foreach(
$ciudades as $ciu)
                   {
                     
$ID2$ciu["idPais"];
                     
$name $ciu["nombre"];
                     
                      if(
$update2==&& ($ID2 == $ciudad['idPais']) )
                       {
                        
?>
                        <option value="<?php echo $ID2 ?>" selected="selected"><?php echo $name ?></option>
                        <?php
                       
}
                       else
                       {
                        
?>
                        <option value="<?php echo $ID2 ?>"><?php echo $name  ?></option>
                        <?php                       
                       
}
                   } 
              }
        }
        
//------- end  SUBCATEGORIES______________________________________________________
        
?>
          </select>
          </span></div></td>
    </tr>
  </table>
</form>
</body>
</html>
gracias por la ayuda ...
__________________
"La vida sigue su curso, tú toma parte de ella."