
cómo mantener estático el scroll vertical mientras navego con mi calendario php
Publicado por Gilberto (6 intervenciones) el 25/03/2016 02:56:14
Hola, por favor me pueden ayudar. Sucede que tengo el calendario en un div en html en mi sitio www.gs-instalaciones.com y cada vez que navego por los meses anteriores o siguientes, me regresa el scroll vertical. intente ponerle top, pero ni aún así se mantiene estático. Anexo script, si alguien desea tenerlo y mejorarlo. Agradezco mucho la ayuda. cuidense.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<script src="js/jquery-1.9.1.min.js"></script>
</head>
<body>
<?php
# definimos los valores iniciales para nuestro calendario
$month=date("n");
$year=date("Y");
$diaActual=date("j");
# Obtenemos el dia de la semana del primer dia
$meses=array(1=>"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio",
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
//definimos meses y años pasados, meses y años posteriores
if (!isset($_REQUEST["mes"])) $_REQUEST["mes"] = date("n");
if (!isset($_REQUEST["anio"])) $_REQUEST["anio"] = date("Y");
$month = $_REQUEST["mes"];
$year = $_REQUEST["anio"];
$prev_year = $year;
$next_year = $year;
$prev_month = $month-1;
$next_month = $month+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $year - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $year + 1;
}
?>
<table id="fecha">
<?php
echo '<div id="#top">';
$previo=$_SERVER['PHP_SELF'].'?mes='. $prev_month.'&anio='.$prev_year.'#top';
$next=$_SERVER["PHP_SELF"]."?mes=". $next_month."&anio=".$next_year .'#top';
echo '</div>';
echo'<caption>';
echo'<a href='.$previo.'>';
echo'<img src="imagen/right.jpg" align="left"></a>';
echo'<a href='.$next.'>';
echo '<img src="imagen/left.jpg" align="right"></a>';
echo $meses[$month].", ".$year ;
echo '</caption>';
?>
<tr>
<th>Lun</th><th>Mar</th><th>Mie</th><th>Jue</th>
<th>Vie</th><th>Sab</th><th class="dom">Dom</th>
</tr>
<tr bgcolor="#ececec">
<?php
# Devuelve 0 para domingo, 6 para sabado
$diaSemana=date("w",mktime(0,0,0,$month,1,$year))+7;
# Obtenemos el ultimo dia del mes
$ultimoDiaMes=date("d",(mktime(0,0,0,$month+1,1,$year)-1));
$last_cell=$diaSemana+$ultimoDiaMes;
// hacemos un bucle hasta 43, que es el máximo de valores que puede
// haber... 6 columnas de 7 dias
for($i=1;$i<=43;$i++)
{
if($i==$diaSemana)
{
// determinamos en que dia empieza
$day=1;
}
if($i<$diaSemana || $i>=$last_cell)
{
// celca vacia
echo "<td> </td>";
}else{
// mostramos el dia
if($day==$diaActual)
echo "<td class='hoy'>$day</td>";
else
echo "<td>$day</td>";
$day++;
}
// cuando llega al final de la semana, iniciamos una columna nueva
if($i%7==0)
{
echo "</tr><tr>\n";
}
}
?>
</tr>
</table>
</body>
</html>
- calendario.rar(1,2 KB)
Valora esta pregunta


0