Foros del Web » Programando para Internet » Javascript »

reloj cuenta atras

Estas en el tema de reloj cuenta atras en el foro de Javascript en Foros del Web. Buenas al fin lo logre, consegui hacer el reloj cuenta atras, acá el script : Código PHP: <?php  require( '/Connections/hoysale.php' );  ?> <?php if (! function_exists ...
  #1 (permalink)  
Antiguo 26/11/2012, 05:40
 
Fecha de Ingreso: junio-2011
Mensajes: 39
Antigüedad: 12 años, 9 meses
Puntos: 2
reloj cuenta atras

Buenas al fin lo logre, consegui hacer el reloj cuenta atras, acá el script :

Código PHP:
<?php require('/Connections/hoysale.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_detalleofertas "-1";
if (isset(
$_GET['detalle'])) {
  
$colname_detalleofertas $_GET['detalle'];
}
mysql_select_db($database_hoysale$hoysale);
$query_detalleofertas sprintf("SELECT * FROM ofertas WHERE id_ofertas = %s"GetSQLValueString($colname_detalleofertas"int"));
$detalleofertas mysql_query($query_detalleofertas$hoysale) or die(mysql_error());
$row_detalleofertas mysql_fetch_assoc($detalleofertas);
$totalRows_detalleofertas mysql_num_rows($detalleofertas);
?>
<!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"><!-- InstanceBegin template="/Templates/index.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Detalle de Oferta</title>
<script type="text/javascript">
function cdtd() {
var xmas = new Date("<?php echo $row_detalleofertas['fecha_de_cierre']; ?>");
var now = new Date();
var timeDiff = xmas.getTime() - now.getTime();
if (timeDiff <= 0) {
        clearTimeout(timer);
document.write("Oferta Terminada!");
// Run any code needed for countdown completion here
    }
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
hours %= 24;
    minutes %= 60;
    seconds %= 60;
document.getElementById("hoursBox").innerHTML = hours;
document.getElementById("minsBox").innerHTML = minutes;
document.getElementById("secsBox").innerHTML = seconds;
var timer = setTimeout('cdtd()',1000);
}
</script>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="/css/thrColLiqHdr.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* este margen negativo de 1 px puede situarse en cualquiera de las columnas de este diseño con el mismo efecto corrector. */
ul.nav a { zoom: 1; }  /* la propiedad de zoom da a IE el desencadenante hasLayout que necesita para corregir el espacio en blanco extra existente entre los vínculos */
</style>
<![endif]-->
<style type="text/css">
a:link {
    color: #09F;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
a:active {
    text-decoration: none;
}
</style>
</head>

<body>
<div class="container">
  <div class="header"><!-- end .header -->
    <hr id="regla" />
    <p> 
    <?php include("/cabezera.php"); ?>
    </p>
  </div>
  <!-- InstanceBeginEditable name="Editarsidebar1" -->
  <div class="sidebar1">
    <ul class="nav">
      <li></li>
    </ul>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <!-- end .sidebar1 -->
  </div>
  <!-- InstanceEndEditable -->
  
  <div class="content">
    <h1><!-- InstanceBeginEditable name="Editarcontenido" -->Detalle de Oferta...<!-- InstanceEndEditable --></h1>
    <p>
    </p>
    <!-- InstanceBeginEditable name="Editarcontenido1" -->
    <p></a>.</p>
    <!-- InstanceEndEditable -->
    <h2><!-- InstanceBeginEditable name="Editarcontenido2" --><!-- InstanceEndEditable --></h2>
    <!-- InstanceBeginEditable name="Editarcontenido3" -->
    <table width="100%">
      <tr>
        <td colspan="3"><strong><?php echo $row_detalleofertas['Titulo']; ?></strong></td>
        <td width="46%" align="right">Id oferta#<?php echo $row_detalleofertas['id_ofertas']; ?></td>
      </tr>
      <tr>
        <td align="center" valign="middle"><p class="precio">                     <?php echo $row_detalleofertas['Precio']; ?></p></td>
        <td colspan="3" rowspan="3"><img src="<?php if ($row_detalleofertas['imagen0'] != "") { echo ''.$row_detalleofertas['imagen0'].''; }else{ echo '/imagenesdelsitio/Pictures-Nikon-icon.png';} ?>" width="300" height="300" align="middle" />&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
Términa en :
<table width="100%">
  <tr>
    <td height="73" bgcolor="#999900">Hor<div id="hoursBox"></div></td>
    <td bgcolor="#FFCC00"> Min<div id="minsBox"></div></td>
    <td bgcolor="#CCCCCC">Seg<div id="secsBox"></div></td>
  </tr>
</table>
<script type="text/javascript">cdtd();</script></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="31%">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <!-- InstanceEndEditable -->
  <!-- end .content --><!-- InstanceBeginEditable name="EditRegion9" -->
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="EditRegion10" -->
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <!-- InstanceEndEditable --></div>
  <!-- InstanceBeginEditable name="Editarsidebar" -->
  <div class="sidebar2">
    <h4></p>
    <!-- end .sidebar2 -->
  </div>
  <!-- InstanceEndEditable -->
  <div class="footer">
    <table width="100%">
      <tr align="center" valign="middle" class="footer" id="fin">
        <th scope="col"><span title="Hoy sale Uruguay ">*</span>*|*<a href="/contactar.php" title="Contáctanos" rel="nofollow">Contáctanos</a> *|*<span title="Mapa del sitio">*</span><a href="/sitemap" title="MAPA DEL SITIO" rel="nofollow">Mapa del sitio</a> *|*<a href="/ayuda.php" title="Ayuda" rel="nofollow">Ayuda</a> *|*<a href="/terminos-y-condiciones.php" title="Términos y condiciones" rel="nofollow">Términos y condiciones</a> *|*<a href="javascript:favoritos('http://www.hoysale.com.','Hoy Sale Uruguay')" title="Agregar a Favoritos" rel="nofollow">Agregar a Favoritos |</a></th>
      </tr>
      <tr align="center" valign="middle">
        <th scope="col">Hoysale.com &copy; 2012 </th>
      </tr>
    </table>
  </div>
  <p>&nbsp;</p>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($detalleofertas);
?>
lo que ahora estoy complicado es que cuando termina la hora puesta por el usuario en ves de poner Oferta Terminada!

vuelve a poner otras 24 horas para el fin del mismo y asi sucesivamente, si me pueden ayudar muy agradecido...
  #2 (permalink)  
Antiguo 26/11/2012, 05:41
 
Fecha de Ingreso: junio-2011
Mensajes: 39
Antigüedad: 12 años, 9 meses
Puntos: 2
Respuesta: reloj cuenta atras

aca dejo el script del reloj :
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. function cdtd() {
  3. var xmas = new Date("<?php echo $row_detalleofertas['fecha_de_cierre']; ?>");
  4. var now = new Date();
  5. var timeDiff = xmas.getTime() - now.getTime();
  6. if (timeDiff <= 0) {
  7.         clearTimeout(timer);
  8. document.write("Oferta Terminada!");
  9. // Run any code needed for countdown completion here
  10.     }
  11. var seconds = Math.floor(timeDiff / 1000);
  12. var minutes = Math.floor(seconds / 60);
  13. var hours = Math.floor(minutes / 60);
  14. hours %= 24;
  15.     minutes %= 60;
  16.     seconds %= 60;
  17. document.getElementById("hoursBox").innerHTML = hours;
  18. document.getElementById("minsBox").innerHTML = minutes;
  19. document.getElementById("secsBox").innerHTML = seconds;
  20. var timer = setTimeout('cdtd()',1000);
  21. }
  22. </script>

Etiquetas: atras, html, mysql, reloj, sql, usuarios
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 02:27.