Foros del Web » Programando para Internet » PHP »

deshabiltar boton

Estas en el tema de deshabiltar boton en el foro de PHP en Foros del Web. Existe la forma en php de deshabilitaro desactivar un boton por un tiempo determinado, por ejm por dos horas? Lo que requiero es deshabilitar o ...
  #1 (permalink)  
Antiguo 05/11/2009, 17:07
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
deshabilitar/desactivar boton

Existe la forma en php de deshabilitaro desactivar un boton por un tiempo determinado, por ejm por dos horas?
Lo que requiero es deshabilitar o desactivar un boton de tal manera q luego de un tiempo este habiltado nuevamente
Vi que se podia hacer conradio button
Mi pregunta surge de la idea de controlar el horario de un personal ; que ingrese en un determiando tiempo y luego de ello no podra cliquear sobre el boton ingreso ya que llego tarde


Esa es la idea que teng osi alguien puede asesorareme quedaria agradecido
Si desean ver mi codigo pues aqui se los mando
Cita:
<?
session_start();
include("include/bd.php");
include("include/functions.php");
bd_connect();





?>


<html>
<head>
<head>
<title>REGISTRO</title>
<h1 ALIGN="center"></H1>

</head>


<script language="JavaScript" type="text/javascript">
function validaBusq() {
if(document.frmPersonal.codigo.value == "" ) {
alert("Debe ingresar su codigo de acceso");
document.frmPersonal.codigo.focus();
return false;
}
return true;
}

</script>
</head>

<body>
<?include ("cabecera.php");?>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;o bj.height=40;obj.wmode="transparent";showClock(obj );</script>


<br>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="contenido_resutl2.php" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top">

<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><p class="clsLblTituloPagina">Pagina de Inicio</p></td>
</tr>
<tr>
<td><hr></td>
</tr>
</table><br>

<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
</table>
Eliga su registro
<br>
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">
<input type="button" name="Ingreso" value="Registro Ingreso" onclick="document.location='ingreso.php'">

<input type="button" name="exit" value="Registro Salida" onclick="document.location='salida.php'">





</td>
</tr>
</table>

<br>
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0
src="pagina_blanco.php" frameborder=1
width=100% scrolling=no height="170"></iframe>-->

</tr>
<tr>
<td colspan="5" height="1" bgcolor="#000000"></td>
</tr>
</table>

</td>
</tr>
</table>
</div>
<??>

</td>
</tr>
</table>

</td>
</tr>
</table>
<font style="font-size:15px;"><SCRIPT LANGUAGE="Javascript"><!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Domingo','Lunes','Martes'Miércoles','Jueves ','Viernes','S&aacute;bado');

// Array list of months.
var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Ju nio','Julio','Agosto','Septiembre','Octubre','Novi embre','Diciembre');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}

// Join it all together
today = days[now.getDay()] + " " +
date + " " +
months[now.getMonth()] + " " +
(fourdigits(now.getYear())) ;

// Print out the data.
document.write("" +today+ " ");

//--></SCRIPT></font></td>

<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
<?include("pie.php");?>
</body>
Lo de azul son los botones
Gracias adelantadas

Última edición por lobbys; 10/11/2009 a las 15:02
  #2 (permalink)  
Antiguo 10/11/2009, 14:43
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: deshabiltar boton

nadie??? alguna pista aunque sea
  #3 (permalink)  
Antiguo 13/11/2009, 16:27
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: deshabiltar boton

hola
ps modifique mi codigo y loque deseo es que e l boton ingreso pueda volver a ser habilitado despusde 4 horas como lo hago?
Posteo mi codigo con las modificacionesque hice:
Código PHP:
<?
session_start
();
include(
"include/bd.php");
include(
"include/functions.php");
bd_connect();





?>


<html>
<head>
    <head>
    <title>REGISTRO</title>
        <h1 ALIGN="center"></H1>
        
</head>


<script language="JavaScript" type="text/javascript">
function validaBusq() {
    if(document.frmPersonal.codigo.value == "" ) {
        alert("Debe ingresar su codigo de acceso");
        document.frmPersonal.codigo.focus();
        return false;
    }
    return true;
}

</script>
</head>
        
<body>
<?include ("cabecera.php");?>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;obj.height=40;obj.wmode="transparent";showClock(obj);</script>


<br>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="ingreso.php" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
    <td valign="top">
    
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center"><p class="clsLblTituloPagina">Pagina de Inicio</p></td>
        </tr>
        <tr>
            <td><hr></td>
        </tr>
        </table><br>
                
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
                </table>
        Eliga su registro
        <br>
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center">
<?
$Fecha
date('d-m-Y',time()); 
$Horadate('H:i:s',time()+3600  ); 
?>                
    
<?php
if ($Hora date ('09:10:00',time())){ 
       echo 
'<input type="submit" value="Registro Ingreso" disabled>';
                              

  }    
else{ 
     
  echo 
'<input type="submit" value="Registro Ingreso">';


    } 
?>  
                              
                           <input type="button" name="exit" value="Registro Salida" onclick="document.location='salida.php'">

  
            </td>
        </tr>
        </table>
        
        <br>
        <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
              <td>
                <!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0 
                    src="pagina_blanco.php" frameborder=1 
                    width=100% scrolling=no height="170"></iframe>-->
                    
                        </tr>
                        <tr>
                            <td colspan="5" height="1" bgcolor="#000000"></td>
                        </tr>
                                                </table>
                        
                    </td>
                </tr>
                </table>
                </div>
                <??>

            </td>
        </tr>
          </table>


        










    </td>
</tr>
</table>
<font style="font-size:15px;"><SCRIPT LANGUAGE="Javascript"><!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Domingo','Lunes','Martes'Miércoles','Jueves','Viernes','S&aacute;bado');

// Array list of months.
var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)    {
    return (number < 1000) ? number + 1900 : number;
                                }

// Join it all together
today =  days[now.getDay()] + " " +
              date + " " +
              months[now.getMonth()] + " " +               
                (fourdigits(now.getYear())) ;

// Print out the data.
document.write("" +today+ " ");
  
//--></SCRIPT></font></td> 

<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
<?include("pie.php");?>
</body>
  #4 (permalink)  
Antiguo 13/11/2009, 20:40
Avatar de arthpix  
Fecha de Ingreso: diciembre-2003
Ubicación: Cancún
Mensajes: 2.340
Antigüedad: 20 años, 4 meses
Puntos: 93
Respuesta: deshabiltar boton

Usa varias condicionales anidadas y si solo necesitas la hora, no es necesario mostrar la fecha, tampoco es necesario usar milisegundos ni timestamp.

Código php:
Ver original
  1. $hora = date("H:m:s"); // Devuelve la hora en formato 24h ej: 09:15:32
  2.  
  3. // Si quieres habilitar el boton digamos, solamente hasta las 9:30
  4. if($hora < "09:30:00"){
  5.  echo '<input type="submit" value="Registro Ingreso" />';
  6. }else{
  7. if($hora < "13:00:00"){
  8. // Si es menor a las 13:00 mantendrá el botón deshabilitado
  9.  echo '<input type="submit" value="Registro Ingreso" disabled />';
  10. }else{
  11. // Si lo anterior no se cumple, vuelve a habilitar el botón
  12.  echo '<input type="submit" value="Registro Ingreso" />';
  13. }
  14. }
__________________
Antes de hacer rabietas infórmate: Linux != Windows
  #5 (permalink)  
Antiguo 17/11/2009, 15:49
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: deshabiltar boton

y dime puedo crear su habilitaciondos veces verdad? solo con condicionales
  #6 (permalink)  
Antiguo 17/11/2009, 19:44
Avatar de arthpix  
Fecha de Ingreso: diciembre-2003
Ubicación: Cancún
Mensajes: 2.340
Antigüedad: 20 años, 4 meses
Puntos: 93
Respuesta: deshabiltar boton

las veces que quieras.
__________________
Antes de hacer rabietas infórmate: Linux != Windows
  #7 (permalink)  
Antiguo 24/11/2009, 20:57
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: deshabiltar boton

Gracias tu ayuda me valio de mucho
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 01:42.