Hi guys.
I'm trying to pick 2 dates from a calendar on my webpage.
I've got 2 textboxes (date1 and date2) and the calendar image next to each of them which opens a separate window with the calendar.
It's all working fine, except for the fact that I can not seem to get the second date, even though I'm choosing it from the calendar. I'm not very skilled in Javascript, but I think the problem is within the insertdate() function and I don't know hoe to fix it.
I appreciate any help.
Here's the relevant pieces of code:
//mypage.php
...
...
echo"";
echo"";
echo "";
echo"";
echo"";
...
//scripts.js
function viewcalendar() {
kalendarik = window.open("php_calendar/calendar.php", "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(250, 50);
}
function insertdate(d) {
window.close();
window.opener.document.getElementById('date').value = d;
}
//calendar.php
include 'configure.php';
$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 '
«
'.$month_names[date('n', mktime(0,0,0,$month,1,date('Y')))].' '.date('Y', mktime(0,0,0,$month,1,date('Y'))).'
»
';
for ($d=0;$d<7;$d++) {
echo '
'.$day_names[$d].'';
}
echo '
';
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 '
'.($minulost? date('j', $i) : ''.date('j', $i).'').'';
} else {
echo '
';
}
if (date('w', $i) == 0 && $i >= $pd) {
echo '
';
}
}