Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/05/2007, 01:06
Avatar de Shiryu_Libra
Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 1 mes
Puntos: 88
Re: combo a condicion

imagino que las horas las rellenas mediante la base de datos y rellenas un arreglo con todas las horas, quiero pensar

bueno... un ejemplo de como podria ser.... recuerda el formato del horario para que no tengas errores

Cita:
01:00 A.M.
14:00 P.M.
Código PHP:
<&#37;
'CONSTRUCCION DEL ARREGLO, MEDIANTE EL LLAMADO A LA BASE
dim H_ocupadas(0)
SQL="GENERAS TU CONSULTA DE LAS HORAS"
i=0
WHILE RS.EOF=FALSE
    REDIM PRESERVER H_ocupadas(i)=RS("CAMPO").value
    i=i+1
WEND

'
ARREGLO AUTOGENERADO CON LAS 24 HORAS DEL DIA.... ESTE PUEDE VARIAR DEPENDIENDO DE LAS
'HORAS QUE VAYAS A ASIGNAR EN EL DIA
DIM H_libres(23)
for i=0 to 23
    if (i<10) then
        H_libres(i)="0"&i&":00 A.M."
    else
        if (i<12 and i>9) then 
            H_libres(i)=i&":00 A.M."
        else
            if i<24 then
                H_libres(i)=i&":00 P.M."
            end if
        end if
    end if
next

'
CREAR EL SELECT CON LAS HORAS QUE ESTARAN DISPONIBLES PARA EL DIA ENTEROEL CUAL SERA
'COMPARADO CON EL ARREGLO QUE SE FORME EN LA CONSULTA
response.Write "<select id=libres>"
for i=0 to ubound(H_libres)
    for j=0 to ubound(H_ocupadas)
        if H_ocupadas(j)<>H_libres(i) then 
            temp=temp+1
        else
            j=ubound(H_ocupadas)+10
        end if
        if temp=ubound(H_ocupadas) then 
            response.Write "<option value="&i&">"&H_libres(i)&"</option>"
            temp=0
        end if
    next
next
response.Write "</select>"

'
CREAR EL SELECT DE LAS HORAS QUE ESTEN EN EL ARREGLO LLENADO POR LA CONSULTA EN BASE DE DATOS
response
.Write "<select id=ocupadas>"
for i=0 to ubound(H_ocupadas)
    
response.Write "<option value="&i&">"&H_ocupadas(i)&"</option>"
next
response
.Write "</select>"
%> 
realmente no se si exista algo mas corto, pero pues funciona... el trozo de codigo pegado, compara las 24 horas del dia... contra un arreglo generado mediante consulta directa con tu base....

suerte
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra