Привет. Нужно в форме сделать поле, где будет выбираться дата (желательно еще выбор времии) как в phpmyadmin... есть там поля для ввода даты, при нажатии на кнопку вылазит окошко с календарем, там выбираешь дату и после нажатия эта дата переноситься в поле... пытался выдрать из phpmyadmin`а, но скрипт не желает работать... ошибку никак не могу исправить... Подскажите как его выдрать? какие файлы нужны? может кто уже делал это? P.S. Нашел такой пример: Код (Text): <script> /** * Opens calendar window. * * @param string calendar.php parameters * @param string form name * @param string field name * @param string edit type - date/timestamp */ function openCalendar(params, form, field, type) { window.open("calendar.php", "calendar", "width=400,height=300,status=yes"); dateField = eval("document." + form + "." + field); dateType = type; } </script> <input size="50" name="date" value=""> <script type="text/javascript" language="javascript"> document.write('<a title="Calendar" href="javascript:openCalendar(\'\', \'adminForm\', \'date\', \'datetime\')">Calendar</a>'); </script> calendar.php Код (Text): <html> <head> <style> /* Calendar */ table.calendar { width: 100%; } table.calendar td { text-align: center; } table.calendar td a { display: block; } table.calendar td a:hover { background-color: #7fcaff; } table.calendar th { background-color: #daf0ff; } table.calendar td.selected { background-color: #bfd9eb; } img.calendar { border: none; } form.clock { text-align: center; } /* end Calendar */ </style> <script> var day; var month; var year; var hour; var minute; var second; /** * Formats number to two digits. * * @param int number to format. * @param string type of number */ function formatNum2(i, valtype) { f = (i < 10 ? '0' : '') + i; if (valtype && valtype != '') { switch(valtype) { case 'month': f = (f > 12 ? 12 : f); break; case 'day': f = (f > 31 ? 31 : f); break; case 'hour': f = (f > 24 ? 24 : f); break; default: case 'second': case 'minute': f = (f > 59 ? 59 : f); break; } } return f; } /** * Formats number to two digits. * * @param int number to format. * @param int default value * @param string type of number */ function formatNum2d(i, default_v, valtype) { i = parseInt(i, 10); if (isNaN(i)) return default_v; return formatNum2(i, valtype) } /** * Formats number to four digits. * * @param int number to format. */ function formatNum4(i) { i = parseInt(i, 10) return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i; } /** * Initializes calendar window. */ function initCalendar() { var month_names; var day_names = new Array(); day_names[0] = "Sun"; day_names[1] = "Mon"; day_names[2] = "Tue"; day_names[3] = "Wed"; day_names[4] = "Thu"; day_names[5] = "Fri"; day_names[6] = "Sat"; var clock_set = 0; if (!year && !month && !day) { if(window.opener.dateField.value) { value = window.opener.dateField.value; if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') { if (window.opener.dateType == 'datetime') { parts = value.split(' '); value = parts[0]; if (parts[1]) { time = parts[1].split(':'); hour = parseInt(time[0],10); minute = parseInt(time[1],10); second = parseInt(time[2],10); } } date = value.split("-"); day = parseInt(date[2],10); month = parseInt(date[1],10) - 1; year = parseInt(date[0],10); } else { year = parseInt(value.substr(0,4),10); month = parseInt(value.substr(4,2),10) - 1; day = parseInt(value.substr(6,2),10); hour = parseInt(value.substr(8,2),10); minute = parseInt(value.substr(10,2),10); second = parseInt(value.substr(12,2),10); } } if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) { dt = new Date(); year = dt.getFullYear(); month = dt.getMonth(); day = dt.getDate(); } if (isNaN(hour) || isNaN(minute) || isNaN(second)) { dt = new Date(); hour = dt.getHours(); minute = dt.getMinutes(); second = dt.getSeconds(); } } else { if (month > 11) { month = 0; year++; } if (month < 0) { month = 11; year--; } } if (document.getElementById) { cnt = document.getElementById("calendar_data"); } else if (document.all) { cnt = document.all["calendar_data"]; } cnt.innerHTML = ""; str = ""; //heading table str += '<table class="calendar" border="0"><tr><th width="50%">'; str += '<form method="NONE" onsubmit="return 0">'; str += '<a href="javascript:month--; initCalendar();">«</a> '; str += '<select id="select_month" name="monthsel" onchange="month = parseInt(document.getElementById(\'select_month\').value); initCalendar();">'; for (i =0; i < 12; i++) { if (i == month) selected = ' selected="selected"'; else selected = ''; j = i + 1; str += '<option value="' + i + '" ' + selected + '>' + j + '</option>'; } str += '</select>'; str += ' <a href="javascript:month++; initCalendar();">»</a>'; str += '</form>'; str += '</th><th width="50%">'; str += '<form method="NONE" onsubmit="return 0">'; str += '<a href="javascript:year--; initCalendar();">«</a> '; str += '<select id="select_year" name="yearsel" onchange="year = parseInt(document.getElementById(\'select_year\').value); initCalendar();">'; for (i = year - 25; i < year + 25; i++) { if (i == year) selected = ' selected="selected"'; else selected = ''; str += '<option value="' + i + '" ' + selected + '>' + i + '</option>'; } str += '</select>'; str += ' <a href="javascript:year++; initCalendar();">»</a>'; str += '</form>'; str += '</th></tr></table>'; str += '<table class="calendar"><tr>'; for (i = 0; i < 7; i++) { str += "<th>" + day_names[i] + "</th>"; } str += "</tr>"; var firstDay = new Date(year, month, 1).getDay(); var lastDay = new Date(year, month + 1, 0).getDate(); str += "<tr>"; dayInWeek = 0; for (i = 0; i < firstDay; i++) { str += "<td> </td>"; dayInWeek++; } for (i = 1; i <= lastDay; i++) { if (dayInWeek == 7) { str += "</tr><tr>"; dayInWeek = 0; } dispmonth = 1 + month; if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') { actVal = "" + formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day'); } else { actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day'); } if (i == day) { style = ' class="selected"'; current_date = actVal; } else { style = ''; } str += "<td" + style + "><a href=\"javascript:returnDate('" + actVal + "');\">" + i + "</a></td>" dayInWeek++; } for (i = dayInWeek; i < 7; i++) { str += "<td> </td>"; } str += "</tr></table>"; cnt.innerHTML = str; // Should we handle time also? if (window.opener.dateType != 'date' && !clock_set) { if (document.getElementById) { cnt = document.getElementById("clock_data"); } else if (document.all) { cnt = document.all["clock_data"]; } var submit_text; str = ''; init_hour = hour; init_minute = minute; init_second = second; str += '<form method="NONE" class="clock" onsubmit="returnDate(\'' + current_date + '\')">'; str += '<input id="hour" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_hour, \'hour\'); init_hour = this.value;" value="' + formatNum2(hour, 'hour') + '" />:'; str += '<input id="minute" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_minute, \'minute\'); init_minute = this.value;" value="' + formatNum2(minute, 'minute') + '" />:'; str += '<input id="second" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_second, \'second\'); init_second = this.value;" value="' + formatNum2(second, 'second') + '" />'; str += '<br /><br />'; str += '<input type="submit" value="Set"/>'; str += '</form>'; cnt.innerHTML = str; clock_set = 1; } } /** * Returns date from calendar. * * @param string date text */ function returnDate(d) { txt = d; if (window.opener.dateType != 'date') { // need to get time h = parseInt(document.getElementById('hour').value,10); m = parseInt(document.getElementById('minute').value,10); s = parseInt(document.getElementById('second').value,10); if (window.opener.dateType == 'datetime') { txt += ' ' + formatNum2(h, 'hour') + ':' + formatNum2(m, 'minute') + ':' + formatNum2(s, 'second'); } else { // timestamp txt += formatNum2(h, 'hour') + formatNum2(m, 'minute') + formatNum2(s, 'second'); } } window.opener.dateField.value = txt; window.close(); } </script> </head> <body onload="initCalendar();"> <div id="calendar_data"></div> <div id="clock_data"></div> </body> </html> Но выдает ошибку: - это тут (... if(window.opener.dateField.value) ...) Код (Text): Ошибка: "window.opener.dateField.value" - есть null или не является объектом