Prova questo.
Ciliegina sulla torta la finestrina si posiziona vicino all'elemento.
Da mettere nello script principale
Codice PHP:
<script>
function viewcalendar(buttonObj,campodata)
{
// da me calendar.php sta nella stessa cartella dello script richiamante - da cancellare
kalendarik = window.open("calendar.php?campo="+campodata, "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1");
// Togliere il commento
//kalendarik = window.open("php_calendar/calendar.php?campo="+campodata, "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1, width=200, height=240, top=50, left=250");
kalendarik.resizeTo(200, 240);
kalendarik.moveTo(buttonObj.offsetLeft, buttonObj.offsetTop + buttonObj.scrollTop);
}
</script>
<input name="campodata2" type="text" id="campodata2" size="12" maxlength="12"/><input type="button" value="..." onclick="viewcalendar(this,'campodata2')"/>
<br/><br/><br/><br/><br/><br/>
<input name="campodata3" type="text" id="campodata3" size="12" maxlength="12"/><input type="button" value="..." onclick="viewcalendar(this,'campodata3')"/>
calendar.php
Codice PHP:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="us" lang="us">
<head>
<title>PHP Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<meta http-equiv="Content-Language" content="sk" />
<meta name="copyright" content="(c) 2005 separd" />
<link href="style.css" type="text/css" rel="stylesheet" />
<script src="scripts.js" type="text/javascript"></script>
<script>
function rinvia(d)
{
window.close();
window.opener.document.getElementById('<?php print $_GET['campo'];?>').value = d;
}
</script>
</head>
<body>
<?php
// ******** togliere il commento qui sotto
//include 'configure.php';
// ******** cancellare da qui
$month_names = array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Novembre','Dicembre');
$day_names = array('Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato','Domenica');
$allow_past = true;
$date_format = 'd/m/Y';
// ******** fino a qui
$month = isset($_GET['month'])? $_GET['month'] : date('n');
$pd = mktime (0,0,0,$month,1,date('Y'));// timestamp of the first day
$zd = -(date('w', $pd)? (date('w', $pd)-1) : 6)+1;// monday before
$kd = date('t', $pd);// last day of moth
echo '
<div class="month_title">
<a href="calendar.php?month='.($month-1).'" class="month_move">«</a>
<div class="month_name">'.$month_names[date('n', mktime(0,0,0,$month,1,date('Y')))].' '.date('Y', mktime(0,0,0,$month,1,date('Y'))).'</div>
<a href="calendar.php?month='.($month+1).'" class="month_move">»</a>
<div class="r"></div>
</div>';
for ($d=0;$d<7;$d++) {
echo '
<div class="week_day">'.$day_names[$d].'</div>';
}
echo '
<div class="r"></div>';
for ($d=$zd;$d<=$kd;$d++) {
$i = mktime (0,0,0,$month,$d,date('Y'));
if ($i >= $pd) {
$today = (date('Ymd') == date('Ymd', $i))? '_today' : '';
$minulost = (date('Ymd') >= date('Ymd', $i+86400)) && !$allow_past;
echo '
<div class="day'.$today.'">'.($minulost? date('j', $i) : '<a title="'.date('Ymd', $i).'" href="javascript:rinvia(\''.date($date_format, $i).'\')">'.date('j', $i).'</a>').'</div>';
} else {
echo '
<div class="no_day"> </div>';
}
if (date('w', $i) == 0 && $i >= $pd) {
echo '
<div class="r"></div>';
}
}?>
</body>
</html>';