Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/09/2011, 14:55
pebre_cco
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 13 años, 7 meses
Puntos: 0
textbox + select en php y ajax

amigos primero quiero dar la gracias por el hecho de leer mi inquietud .... el motivo por el que escribo es porque necesito que me ayuden con un problema de mi universidad.


Estoy haciendo una agenda de dacion de horas y no se como actualizar el select a partir de los datos ingresados en un textbox.

Averigue de como hacerlo en ajax pero nose porque no funciona.

les doy una captura de imagen

de como quiero que quede



este es mi codigo de xajax (cosa que modifique de otra pagina) para generar el select con las horas disponibles.

Código PHP:
<?PHP
include('../Php/conexion.inc.php');
include(
'../Php/funciones.php');

require(
'../Xajax/xajax_core/xajax.inc.php');

$xajax = new xajax(); 
$xajax->setCharEncoding('ISO-8859-1');
$xajax->configure('decodeUTF8Input',true);

//funcion donde comparo los dos arreglo y genero un arreglo con los cupos disponibles
function horas($fecha)
{
       
$link Conectarse();
    
$select="SELECT con_HORA FROM con_CITACIONES WHERE con_FECHA='$fecha'";
    
$sql_select=mysql_query($select,$link);
    
$arreglo_1=mysql_fetch_array($sql_select);
    
$horas=array('1','2','3','4','5');
    
$nuevo_select='<select name="poblaciones">';
    foreach ( 
$horas as $value2 
    { 
            
$encontrado=false;
               foreach (
$arreglo_1 as $value1)
            {
                if (
$value1 == $value2)
                {
                    
$encontrado=true;
                    
$break;
                }
        }
        if (
$encontrado == false)
        {
         
$nuevo_select .='<option value="'.$value2.'">'.$value2.'</option>';
        }
    }
    
$nuevo_select .='</select>';
    return 
$nuevo_select;
}

function 
generar_select($fecha){
   
$respuesta = new xajaxResponse();
   
$respuesta->setCharacterEncoding('ISO-8859-1');
   
   if (empty(
$fecha)){
      
$nuevo_select '<select name="poblaciones">
                  <option value=0>Seleccione Hora</option>
                  </select>
                  '
;
   }else{
      
$nuevo_select horas($fecha);
   }
   
$respuesta->assign("seleccombinado","innerHTML",$nuevo_select);
   
   return 
$respuesta;
}
   
$xajax->register(XAJAX_FUNCTION"generar_select");

$xajax->processRequest();
?>
y este es mi codigo de mi pagina desde donde llamo al evento

Código HTML:
<!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>resultado</title>
<link href="../JS/Calendario/skins/default/calendar.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../JS/Calendario/mootools.js"></script>
<script type="text/javascript" src="../JS/Calendario/calendar.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
   myCal = new Calendar({ fecha: 'd/m/Y' });
});
</script>
<?php
$xajax->printJavascript("../Xajax/");
?>
</head>
<?php
$r_rut=$_GET['r_rut'];
$fr=$_COOKIE['fr'];
$link = Conectarse();

switch ($fr)
{
	case '21' :

		$sql="select * from con_pacientes where con_RUT='$r_rut'";
		$resultados=mysql_query($sql,$link);
		
		$r_rut=mysql_result($resultados,0,"con_RUT");
		$r_nombre=mysql_result($resultados,0,"con_NOMBRE");
		$r_apaterno=mysql_result($resultados,0,"con_APATERNO");
		$r_amaterno=mysql_result($resultados,0,"con_AMATERNO");
		$r_nacimiento=mysql_result($resultados,0,"con_NACIMIENTO");
		$r_edad=calcularEdad($r_nacimiento);
		$r_domicilio=mysql_result($resultados,0,"con_DOMICILIO");
		$r_telefono_1=mysql_result($resultados,0,"con_TEL_1");
		$r_telefono_2=mysql_result($resultados,0,"con_TEL_2");
		
		break ;
}
?>
<body>
<div id="mensaje">
<form name="formulario">
  <p><strong>ASIGNAR HORA</strong></p>
  <table width="570" border="0">
    <tr>
      <td><strong>PROFESIONAL :</strong></td>
      <td width="155"><select name="select" id="select" >
        <option value="1">Agustin Alvarez</option>
      </select></td>
      <td width="10">&nbsp;</td>
      <td width="99">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="184"><strong>DIA :</strong></td>
      <td colspan="3"><input type="text" name="fecha" id="fecha" size="16" onchange="xajax_generar_select(document.formulario.fecha.options[document.formulario.fecha.selectedIndex].value)"></td>
      <td width="100">&nbsp;</td>
    </tr>
    <tr>
      <td><strong>HORA : </strong></td>
      <td colspan="3"><div id="seleccombinado"><select name="poblaciones">
  <option value=0>Seleccionar Hora</option>
</select></div></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p><strong>DATOS PACIENTE</strong></p>
  <table width="570" border="0">
    <tr>
      <td><strong>RUT :</strong></td>
      <td width="155"><input name="r_rut" type="text" disabled="disabled" id="r_rut" style=" BACKGROUND-COLOR: transparent; BORDER: none " value="<?php echo $r_rut; ?>" size="15" readonly="readonly"/></td>
      <td width="10">&nbsp;</td>
      <td width="99">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="184"><strong>NOMBRES : </strong></td>
      <td colspan="3"><?php echo $r_nombre; ?></td>
      <td width="100">&nbsp;</td>
    </tr>
    <tr>
      <td><strong>APELLIDOS : </strong></td>
      <td colspan="3"><?php echo $r_apaterno. " ".$r_amaterno; ?></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td><strong>FECHA NACIMIENTO : </strong></td>
      <td><?php echo $r_nacimiento; ?></td>
      <td>&nbsp;</td>
      <td><strong>EDAD:</strong></td>
      <td><?php echo $r_edad; ?></td>
    </tr>
    <tr>
      <td><strong>DOMICILIO : </strong></td>
      <td colspan="4"><?php echo $r_domicilio; ?></td>
    </tr>
    <tr>
      <td><strong>TELEFONO : </strong></td>
      <td><?php echo $r_telefono_1; ?></td>
      <td>&nbsp;</td>
      <td><strong>TELEFONO : </strong></td>
      <td><?php echo $r_telefono_2; ?></td>
    </tr>
    <tr>
      <td colspan="5" align="center">
        <?php
	  switch ($_COOKIE['fr'])
	  {
		  case '21':
		  echo '<a href="R_HUMANOS/per_admin.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
		  
		  case '22':
		  echo '<a href="R_HUMANOS/per_curso.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
		  
		  case '23':
		  echo '<a href="R_HUMANOS/per_vacaciones.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
		  
		  case '24':
		  echo '<a href="R_HUMANOS/per_licencia.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
		  
		  case '31':
		  echo '<a href="P_MUJER/ingreso_pap.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
		  
		  case '32':
		  echo '<a href="P_MUJER/ingreso_mama.php?r_rut='.$r_rut.'"><img src="Images/siguiente.png" width="40" height="40" border="0" /></a>';
		  break;
	  }
	?>
        </td>
    </tr>
	</table>
  </form>
  <p>&nbsp; </p>
</div>
</body>
</html> 
por favor les pido que me ayuden ya que nose como hacerlo para que funcione ... e tratado de estudiar mas pero no logro saber porque no funciona .... se que estoy fallando en algo pero nose en que es ....


desde ya muchas gracias