Problem with submitting multiple hidden forms

Problem with submitting multiple hidden forms

am 01.10.2007 14:27:58 von esedic

Hi!

I'm novice with php language and I need help.

I'm trying to put together a simple page with html forms in it, the
submitted values would be written in MySQL database using the
insert.php file.


code of insert.php:




content=3D"text/html; charset=3Dwindows-1250">
TEST




TEST PAGE


$con =3D mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql=3D"INSERT INTO database_table (field1, field2, field3)
VALUES
('$_POST[form1]','$_POST[form2]','$_POST[form3]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Thank you!";
?>





Then I have a index.php file with following code




content=3D"text/html; charset=3Dwindows-1250">
Test Page




style=3D"text-align: left; font-family: Verdana; font-size: 11px;
width: 608px; height: 209px;"
border=3D"0" cellpadding=3D"2" cellspacing=3D"2">


FormName1
name=3D"form1">


FormName2



FormName3

value=3D"today" type=3D"hidden"> id=3D"DPC_BUTTON_TITLE" value=3D"Choose Date" type=3D"hidden"> id=3D"DPC_MONTH_NAMES"
value=3D"['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']"
type=3D"hidden"> value=3D"['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']"
type=3D"hidden"> name=3D"form3" size=3D"12" type=3D"text">





value=3D"Send" name=3D"send" type=3D"submit"> value=3D"Clear" name=3D"reset" type=3D"reset">







I don't know what name must I give in $_POST variable for third form
in sql statement in insert.php.
It's a datepicker javascript and it has a multiple hidden input forms,
not just one (in that case, it wouldn't be a problem).

form1 =3D $_POST[form1]
form2 =3D $_POST[form2]
form3 =3D ???

I've tried to use a "form3" value from this line: id=3D"DPC_calendar1" name=3D"form3" size=3D"12" type=3D"text"> , but it
doesn't work

Actually there is a new record in mysql database but the values in
field1, field2 and field3 (except fields id which is auto_increment
and date_added which is timestamp) don't change.

Does anybody know what is going on and what I have to do to make it
work?



Here is the datepickercontrol.js javascript code:

/**
* DatePickerControl.v.1.1.1 beta
*
* Transform your input text control into a date-picker control.
*
* By Hugo Ortega_Hernandez - hugorteg _no_spam_ at gmail dot com
*
* Last version of this code: http://dali.mty.itesm.mx/~hugo/js/datepickerc=
ontrol/
*
* Features:
* + Automatic input control conversion with a single attribute
* in the 'input' tag or a special 'id' attribute format.
* + Multiple date formats.
* + Layered calendar, without pop-up window.
* + Mouse and keyboard navigation.
* + Variable first day of week.
* + Min and Max dates.
* + Easy i18n.
* + CSS support.
*
* License: GPL (i.e., use this code as you wish, just keep it free)
* Provided as is, without any warranty.
* Feel free to use this code, but don't remove this disclaimer
please.
*
* If you're going to use this library, please send me an email, and
* would be great if you include a photo of your city :)
* (se habla español)
*
* Credits:
*
* Functions to calculate days of a year and to generate the calendar
code by:
* Kedar R. Bhave - softricks at hotmail dot com
* http://www.softricks.com
* =3D Modified by Hugo Ortega_H:
* + CSS style
* + Remove non useful code (original version with pop-up window)
* + Clean job :-) (so hard!)
* + Add support for layered calendar
* + Many other stuff.
*
* Other code functions and lines to calculate objects' size &
location by:
* Mircho Mirev - mo at momche dot net
*
* First day of week code by:
* Massimiliano Ciancio - massimiliano at ciancio dot net
*
*
* Veracruz & Monterrey,
Mexico, 2005.
*/


//---------------------------------------------------------- ---------------=
----
// Some parameters for style and behaviour...
// Is better to use global parameters to avoid problems with updates,
// but if you want to override default values, here are the
variables :-)
// (see index.html to see how to use global parameters)

DatePickerControl.defaultFormat =3D "DD.MM.YYYY";
DatePickerControl.submitFormat =3D "YYYY-MM-DD";
DatePickerControl.offsetY =3D 1;
DatePickerControl.offsetX =3D 0;
DatePickerControl.todayText =3D "hoy";
DatePickerControl.buttonTitle =3D "Abrir calendario...";
DatePickerControl.buttonPosition =3D "in"; // or "out"
DatePickerControl.buttonOffsetX =3D 0; // See below for some
considerations about
DatePickerControl.buttonOffsetY =3D 0; // that values (for IE)
DatePickerControl.closeOnTodayBtn =3D true; // close if today button is
pressed?
DatePickerControl.defaultTodaySel =3D true; // If true and content is
blank, today date will be selected
DatePickerControl.autoShow =3D false; // Auto show the calendar
when the input grab the focus.
DatePickerControl.firstWeekDay =3D 1; // First day of week:
0=3DSunday, 1=3DMonday, ..., 6=3DSaturday
DatePickerControl.weekend =3D [0,6]; // Sunday and Saturday as
weekend (maybe a 3-day weekend in France :D , I love it!...)
DatePickerControl.weekNumber =3D false; // Display or not the week
number


DatePickerControl.Months =3D
["Januar", "Februar", "Marec", "April", "Maj", "Junij",
"Julij", "Avgust", "September", "Oktober", "November", "December"];
// ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio",
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
// ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"];
// ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre",
"Décembre"];
// ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli",
"August", "September", "Oktober", "November", "Dezember"];
// ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];

DatePickerControl.Days =3D
["Ned", "Pon", "Tor", "Sre", "=C8et", "Pet", "Sob"];
// ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"];
// ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
// ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"];
// ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"];
// ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"];


//---------------------------------------------------------- ---------------=
----
// Specific patches

DatePickerControl.useTrickyBG =3D false;
// Some people ask me about IE strange behaviour... well, here's the
patch
// IE returns object position with one pixel more
// Patches for IE?, I can't believe!
// There area a LOT of problems with IE, because if you change, for
example,
// the body margin, all control's positions are wrong... agghh... I
hate IE...
// this is why all my projects have a technical requirement: Mozilla
family :-)
if (navigator.userAgent.indexOf("MSIE") > 1){
DatePickerControl.useTrickyBG =3D true;
DatePickerControl.offsetY =3D 0;
DatePickerControl.offsetX =3D -1;
DatePickerControl.buttonOffsetX =3D -4;
DatePickerControl.buttonOffsetY =3D -2;
// but if document have xhtml dtd, things are different... :S
if (document.getElementsByTagName("html")[0].getAttribute("xmln s") !=3D
null){
DatePickerControl.offsetY =3D 16;
DatePickerControl.offsetX =3D 10;
DatePickerControl.buttonOffsetX =3D 8;
DatePickerControl.buttonOffsetY =3D 14;
}
}

//---------------------------------------------------------- ---------------=
----
// Some constants and internal stuff

DatePickerControl.editIdPrefix =3D "DPC_"; // The prefix for
edit's id
DatePickerControl.displayed =3D false; // Is the
calendar layer displayed?
DatePickerControl.HIDE_TIMEOUT =3D 200; // Time in ms for
hide the calendar layer
DatePickerControl.hideTimeout =3D null; // The timeout
identifier
DatePickerControl.buttonIdPrefix =3D "CALBUTTON"; // The prefix for
the calendar button's id
DatePickerControl.dayIdPrefix =3D "CALDAY"; // The prefix for
the calendar days frames' id
DatePickerControl.currentDay =3D 1; // The current
day of current month of current year :-)
DatePickerControl.originalValue =3D ""; // The original
value of edit control
DatePickerControl.calFrameId =3D "calendarframe"; // The id for the
calendar layer
DatePickerControl.submitByKey =3D false; // Is submitting
by keyboard?
DatePickerControl.dayOfWeek =3D 0; // The current
day of current week ...
DatePickerControl.firstFocused =3D false; // Is the first
time that the current edit control is focused?
DatePickerControl.hideCauseBlur =3D false; // Was the
calendar close by onblur event?
DatePickerControl.onSubmitAsigned =3D false; // Is form's
onSubmit event asigned?
DatePickerControl.minDate =3D null; // The minimum
date for the current datepicker
DatePickerControl.maxDate =3D null; // The maximum
date for the current datepicker
DatePickerControl.DOMonth =3D [31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31]; // Non-leap year month days
DatePickerControl.lDOMonth =3D [31, 29, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31]; // Leap year month days


//---------------------------------------------------------- ---------------=
----
// The fun :-)


//---------------------------------------------------------- ---------------=
----
/**
* Constructor (or something like that).
*/
function DatePickerControl()
{
}


//---------------------------------------------------------- ---------------=
----
/**
* Creates the calendar's div element and the button into the input-
texts with
* attibute datepicker=3D"true" or id=3D"DPC_foo_[format]"
*/
DatePickerControl.init =3D function()
{
// try to create the DatePickerControl.container:
if (!document.getElementById("CalendarPickerControl")){

// but first, take a look for global parameters:
this.setGlobalParams();

this.calBG =3D null;
if (this.useTrickyBG){
// Creates a tricky bg to hide the select controls (IE bug).
// We use a iframe element, because is one of the elements that can
// stay on top of select controls.
// I don't like this solution, but IE is a pseudo-browser for
developers
this.calBG =3D document.createElement("iframe");
this.calBG.id =3D "CalendarPickerControlBG";
this.calBG.style.zIndex =3D "49999"; // below calcontainer
this.calBG.style.position =3D "absolute";
this.calBG.style.display =3D "none";
this.calBG.style.border =3D "0px solid transparent";
document.body.appendChild(this.calBG);
}
this.calContainer =3D document.createElement("div");
this.calContainer.id =3D "CalendarPickerControl";
this.calContainer.style.zIndex =3D "50000";
this.calContainer.style.position =3D "absolute";
this.calContainer.style.display =3D "none";
document.body.appendChild(this.calContainer);

if (this.calContainer.addEventListener){
this.calContainer.addEventListener("click", DPC_onContainerClick,
false);
window.addEventListener("resize", DPC_onWindowResize, false);
}
else if (this.calContainer.attachEvent){
this.calContainer.attachEvent("onclick", DPC_onContainerClick);
window.attachEvent("onresize", DPC_onWindowResize);
}
}

// looking for input controls that will be transformed into
DatePickerControl's.
var inputControls =3D document.getElementsByTagName("input");
var inputsLength =3D inputControls.length;
for (i=3D0; i if (inputControls[i].type.toLowerCase() == "text"){
var editctrl =3D inputControls[i];
var dpcattr =3D editctrl.getAttribute("datepicker");
var setEvents =3D false;
// if datepicker pseudo-attribute:
if (dpcattr !=3D null && dpcattr == "true"){
if (editctrl.id){
if (!this.createButton(editctrl, false)) continue;
setEvents =3D true;
}
else{
alert("Attribute 'id' is mandatory for DatePickerControl.");
}
}
// if fomated id attr:
else if (editctrl.id && editctrl.id.indexOf(this.editIdPrefix) == 0)
{
if (!this.createButton(editctrl, true)) continue;
setEvents =3D true;
}
editctrl.setAttribute("isdatepicker", "true");
// add the events:
if (setEvents){
if(editctrl.addEventListener){
editctrl.addEventListener("keyup", DPC_onEditControlKeyUp,
false);
editctrl.addEventListener("keydown", DPC_onEditControlKeyDown,
false);
editctrl.addEventListener("keypress", DPC_onEditControlKeyPress,
false);
editctrl.addEventListener("blur", DPC_onEditControlBlur, false);
editctrl.addEventListener("focus", DPC_onEditControlFocus,
false);
editctrl.addEventListener("change", DPC_onEditControlChange,
false);
}
else if (editctrl.attachEvent){
editctrl.attachEvent("onkeyup", DPC_onEditControlKeyUp);
editctrl.attachEvent("onkeydown", DPC_onEditControlKeyDown);
editctrl.attachEvent("onkeypress", DPC_onEditControlKeyPress);
editctrl.attachEvent("onblur", DPC_onEditControlBlur);
editctrl.attachEvent("onfocus", DPC_onEditControlFocus);
editctrl.attachEvent("onchange", DPC_onEditControlChange);
}
var theForm =3D editctrl.form;
if (!this.onSubmitAsigned && theForm){
this.onSubmitAsigned =3D true;
theForm.submitOrig =3D theForm.submit;
theForm.submit =3D DPC_formSubmit;
if (theForm.addEventListener){
theForm.addEventListener('submit', DPC_onFormSubmit, false);
}
else if (theForm.attachEvent){
theForm.attachEvent('onsubmit', DPC_onFormSubmit);
}
}
}
}
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Set the global parameters.
*/
DatePickerControl.setGlobalParams =3D function()
{
var obj =3D document.getElementById("DPC_DEFAULT_FORMAT");
if (obj) this.defaultFormat =3D obj.value;

obj =3D document.getElementById("DPC_SUBMIT_FORMAT");
if (obj) this.submitFormat =3D obj.value;

obj =3D document.getElementById("DPC_FIRST_WEEK_DAY");
if (obj) this.firstWeekDay =3D (obj.value < 0 || obj.value > 6) ? 0 :
parseInt(obj.value);

obj =3D document.getElementById("DPC_WEEKEND_DAYS");
if (obj) eval("this.weekend =3D " + obj.value);

obj =3D document.getElementById("DPC_AUTO_SHOW");
if (obj) this.autoShow =3D obj.value == "true";

obj =3D document.getElementById("DPC_DEFAULT_TODAY");
if (obj) this.defaultTodaySel =3D obj.value == "true";

obj =3D document.getElementById("DPC_CALENDAR_OFFSET_X");
if (obj) this.offsetX =3D parseInt(obj.value);

obj =3D document.getElementById("DPC_CALENDAR_OFFSET_Y");
if (obj) this.offsetY =3D parseInt(obj.value);

obj =3D document.getElementById("DPC_TODAY_TEXT");
if (obj) this.todayText =3D obj.value;

obj =3D document.getElementById("DPC_BUTTON_TITLE");
if (obj) this.buttonTitle =3D obj.value;

obj =3D document.getElementById("DPC_BUTTON_POSITION");
if (obj) this.buttonPosition =3D obj.value;

obj =3D document.getElementById("DPC_BUTTON_OFFSET_X");
if (obj) this.buttonOffsetX =3D parseInt(obj.value);

obj =3D document.getElementById("DPC_BUTTON_OFFSET_Y");
if (obj) this.buttonOffsetY =3D parseInt(obj.value);

obj =3D document.getElementById("DPC_WEEK_NUMBER");
if (obj) this.weekNumber =3D obj.value == "true";

obj =3D document.getElementById("DPC_MONTH_NAMES");
if (obj) eval("this.Months =3D " + obj.value);

obj =3D document.getElementById("DPC_DAY_NAMES");
if (obj) eval("this.Days =3D " + obj.value);
}


//---------------------------------------------------------- ---------------=
----
/**
* Wrapper for init()
*/
function DPC_autoInit()
{
DatePickerControl.init();
}

if (window.addEventListener){
window.addEventListener("load", DPC_autoInit, false);
}
else if (window.attachEvent){
window.attachEvent("onload", DPC_autoInit);
}


//---------------------------------------------------------- ---------------=
----
/**
* Creates the calendar button for a text-input control and assign
some attributes.
* @param input The associated text-input to create the button.
* @param useId Specify if you want to use the Id of input control to
obtain the format
* @return true is the control has been created, otherwise false
*/
DatePickerControl.createButton =3D function(input, useId)
{
var newid =3D this.buttonIdPrefix + input.id;
if (document.getElementById(newid)) return false; // if exists
previously....
// set the date format
var fmt =3D "";
if (useId){ // get the format from the control's id
var arr =3D input.id.split("_");
var last =3D arr[arr.length-1];
// a not so beauty validation :S
if ((last.indexOf("-")>0 || last.indexOf("/")>0 ||
last.indexOf(".")>0) &&
last.indexOf("YY") >=3D 0 && last.indexOf("D") >=3D 0 &&
last.indexOf("M") >=3D 0){ // is a format
fmt =3D last;
}
else{
fmt =3D this.defaultFormat;
}
}
else{ // get the format from pseudo-attibute
fmt =3D input.getAttribute("datepicker_format");
if (!fmt){
fmt =3D this.defaultFormat;
}
}
input.setAttribute("datepicker_format", fmt);
input.setAttribute("maxlength", fmt.length);

// some new methods for datepickers
input.setMinDate =3D function(d){this.setAttribute("datepicker_min",
d);}
input.setMaxDate =3D function(d){this.setAttribute("datepicker_max",
d);}

// Creates the button
var calButton =3D document.createElement("div");
calButton.id =3D newid;
calButton.title =3D this.buttonTitle;
// Set some attributes to remember the text-input associated
// with this button and its format:
calButton.setAttribute("datepicker_inputid", input.id);
calButton.setAttribute("datepicker_format", fmt);
// Add the event listeners:
if(calButton.addEventListener){
calButton.addEventListener("click", DPC_onButtonClick, false);
}
else if (calButton.attachEvent){
calButton.attachEvent("onclick", DPC_onButtonClick);
}
// add first to have access to the size properties
// if is possible, add to the input's parent node
// just in case we need to hide the button automatically
if (input.parentNode){
input.parentNode.appendChild(calButton);
}
else{
document.body.appendChild(calButton);
}
// Set the style and position:
var nTop =3D getObject.getSize("offsetTop", input);
var nLeft =3D getObject.getSize("offsetLeft", input);
calButton.className =3D "calendarbutton";
calButton.style.zIndex =3D 10000;
calButton.style.cursor =3D "pointer";
calButton.style.top =3D (nTop + Math.floor((input.offsetHeight-
calButton.offsetHeight)/2) + this.buttonOffsetY) + "px";
var btnOffX =3D Math.floor((input.offsetHeight -
calButton.offsetHeight) / 2);
if (this.buttonPosition == "in"){
calButton.style.left =3D (nLeft + input.offsetWidth -
calButton.offsetWidth - btnOffX + this.buttonOffsetX) + "px";
}
else{ // "out"
calButton.style.left =3D (nLeft + input.offsetWidth + btnOffX +
this.buttonOffsetX) + "px";
}
// everything is ok
return true;
}


//---------------------------------------------------------- ---------------=
----
/**
* Show the calendar
*/
DatePickerControl.show =3D function()
{
if (!this.displayed){
var input =3D this.inputControl;
if (input == null) return;
if (input.disabled) return; // just in case ;)
var top =3D getObject.getSize("offsetTop", input);
var left =3D getObject.getSize("offsetLeft", input);
var calframe =3D document.getElementById(this.calFrameId);

this.calContainer.style.top =3D top + input.offsetHeight +
this.offsetY + "px";
this.calContainer.style.left =3D left + this.offsetX + "px";
this.calContainer.style.display =3D "none";
this.calContainer.style.visibility =3D "visible";
this.calContainer.style.display =3D "block";
this.calContainer.style.height =3D calframe.offsetHeight;
if (this.calBG){ // the ugly patch for IE
this.calBG.style.top =3D this.calContainer.style.top;
this.calBG.style.left =3D this.calContainer.style.left;
this.calBG.style.display =3D "none";
this.calBG.style.visibility =3D "visible";
this.calBG.style.display =3D "block";
this.calBG.style.width =3D this.calContainer.offsetWidth;
if (calframe){
this.calBG.style.height =3D calframe.offsetHeight;
}
}
this.displayed =3D true;
input.focus();
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Hide the calendar
*/
DatePickerControl.hide =3D function()
{
if (this.displayed){
this.calContainer.style.visibility =3D "hidden";
this.calContainer.style.left =3D -1000; // some problems with
overlaped controls
this.calContainer.style.top =3D -1000;
if (this.calBG){ // the ugly patch for IE
this.calBG.style.visibility =3D "hidden";
this.calBG.style.left =3D -1000;
this.calBG.style.top =3D -1000;
}
this.inputControl.value =3D this.originalValue;
this.displayed =3D false;
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Gets the name of a numbered month
*/
DatePickerControl.getMonthName =3D function(monthNumber)
{
return this.Months[monthNumber];
}


//---------------------------------------------------------- ---------------=
----
/**
* Obtains the days of a given month and year
*/
DatePickerControl.getDaysOfMonth =3D function(monthNo, p_year)
{
if (this.isLeapYear(p_year)){
return this.lDOMonth[monthNo];
}
else{
return this.DOMonth[monthNo];
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Will return an 1-D array with 1st element being the calculated
month
* and second being the calculated year after applying the month
increment/decrement
* as specified by 'incr' parameter. 'incr' will normally have 1/-1 to
navigate thru
* the months.
*/
DatePickerControl.calcMonthYear =3D function(p_Month, p_Year, incr)
{
var ret_arr =3D new Array();

if (incr == -1) {
if (p_Month == 0) {
ret_arr[0] =3D 11;
ret_arr[1] =3D parseInt(p_Year) - 1;
}
else {
ret_arr[0] =3D parseInt(p_Month) - 1;
ret_arr[1] =3D parseInt(p_Year);
}
}
else if (incr == 1) {
if (p_Month == 11) {
ret_arr[0] =3D 0;
ret_arr[1] =3D parseInt(p_Year) + 1;
}
else {
ret_arr[0] =3D parseInt(p_Month) + 1;
ret_arr[1] =3D parseInt(p_Year);
}
}

return ret_arr;
}


//---------------------------------------------------------- ---------------=
----
/**
* Gets the DatePickerControl HTML code
*/
DatePickerControl.getAllCode =3D function()
{
var vCode =3D "";
vCode +=3D "";
vCode +=3D this.getHeaderCode();
vCode +=3D this.getDaysHeaderCode();
vCode +=3D this.getDaysCode();
vCode +=3D "
";
return vCode;
}


//---------------------------------------------------------- ---------------=
----
/**
* The title and nav buttons
*/
DatePickerControl.getHeaderCode =3D function()
{
var prevMMYYYY =3D this.calcMonthYear(this.month, this.year, -1);
var prevMM =3D prevMMYYYY[0];
var prevYYYY =3D prevMMYYYY[1];

var nextMMYYYY =3D this.calcMonthYear(this.month, this.year, 1);
var nextMM =3D nextMMYYYY[0];
var nextYYYY =3D nextMMYYYY[1];

var gNow =3D new Date();
var vCode =3D "";

var numberCols =3D this.weekNumber ? 8 : 7;

vCode +=3D "";
vCode +=3D this.monthName + "  ";

vCode +=3D " (parseInt(this.year)-1) + "' class=3D'yearbutton' ";
vCode +=3D "onclick=3D'DatePickerControl.build(" + this.month + ", " +
(parseInt(this.year)-1)+");return false;'>«
";
vCode +=3D " " + this.year + " ";

vCode +=3D " (parseInt(this.year)+1) + "' class=3D'yearbutton' ";
vCode +=3D "onclick=3D'DatePickerControl.build(" + this.month + ", " +
(parseInt(this.year)+1) + ");return false;'>»
";
vCode +=3D "";

vCode +=3D " "'>";
vCode +=3D "";

vCode +=3D "";

vCode +=3D "";

vCode +=3D "";

vCode +=3D "
+ prevYYYY + "' ";
vCode +=3D "onclick=3D'DatePickerControl.build(" + prevMM + ", " +
prevYYYY + ");return false;'><<
this.Months[gNow.getMonth()] + " " + gNow.getFullYear() + "' ";
vCode +=3D "onclick=3D'DatePickerControl.build(" + gNow.getMonth() + ", "
+ gNow.getFullYear() + ");DatePickerControl.selectToday();return
false;'>";
vCode +=3D this.todayText + "
+ nextYYYY + "' ";
vCode +=3D "onclick=3D'DatePickerControl.build(" + nextMM + ", " +
nextYYYY + ");return false;'>>>
";
vCode +=3D "";

return vCode;
}


//---------------------------------------------------------- ---------------=
----
/**
* The days' name headers
*/
DatePickerControl.getDaysHeaderCode =3D function()
{
var vCode =3D "";

vCode =3D vCode + "";
if (this.weekNumber){
vCode +=3D " "
}
for (i=3Dthis.firstWeekDay; i vCode +=3D "" + this.Days[i % 7] + " td>";
}
vCode =3D vCode + "";

return vCode;
}


//---------------------------------------------------------- ---------------=
----
/**
* The days numbers code
*/
DatePickerControl.getDaysCode =3D function()
{
var vDate =3D new Date();
vDate.setDate(1);
vDate.setMonth(this.month);
vDate.setFullYear(this.year);

var vFirstDay =3D vDate.getDay();
var vDay =3D 1;
var vLastDay =3D this.getDaysOfMonth(this.month, this.year);
var vOnLastDay =3D 0;
var vCode =3D "";
this.dayOfWeek =3D vFirstDay;

var prevm =3D this.month == 0 ? 11 : this.month-1;
var prevy =3D this.prevm == 11 ? this.year - 1 : this.year;
prevmontdays =3D this.getDaysOfMonth(prevm, prevy);
vFirstDay =3D (vFirstDay == 0 && this.firstWeekDay) ? 7 : vFirstDay;

if (this.weekNumber){
var week =3D this.getWeekNumber(this.year, this.month, 1);
}
vCode +=3D "";
if (this.weekNumber){
vCode +=3D "" + week + "";
}

// Write the last days of previous month
for (i=3Dthis.firstWeekDay; i vCode =3D vCode + "" + (prevmontdays-
vFirstDay+i+1) + "";
}

// Write rest of the 1st week
for (j=3DvFirstDay-this.firstWeekDay; j<7; j++) {
if (this.isInRange(vDay)){
classname =3D this.getDayClass(vDay, j);
vCode +=3D " "' " +
"onClick=3D'DatePickerControl.writeDate(" + vDay + ")' id=3D'" +
this.dayIdPrefix + vDay + "'>" + vDay + "";
}
else{
vCode +=3D "" + vDay + "";
}
vDay++;
}
vCode =3D vCode + "";

// Write the rest of the weeks
for (k=3D2; k<7; k++){
vCode =3D vCode + "";
if (this.weekNumber){
week++;
if (week >=3D 53) week =3D 1;
vCode +=3D "" + week + "";
}
for (j=3D0; j<7; j++){
if (this.isInRange(vDay)){
classname =3D this.getDayClass(vDay, j);
vCode +=3D " classname + "' " +
"onClick=3D'DatePickerControl.writeDate(" + vDay + ")' id=3D'" +
this.dayIdPrefix + vDay + "'>" + vDay + "";
}
else{
vCode +=3D "" + vDay + "";
}
vDay++;
if (vDay > vLastDay){
vOnLastDay =3D 1;
break;
}
}

if (j == 6)
vCode +=3D "";
if (vOnLastDay == 1)
break;
}

// Fill up the rest of last week
for (m=3D1; m<(7-j); m++){
vCode +=3D "" + m + "";
}

return vCode;
}


//---------------------------------------------------------- ---------------=
----
/**
* Get the class according if is 'today', the 'current' date at the
control,
* a 'weekend' day, or a 'normal' day.
* @param vday The number of the day in the current month and year
* @param dayofweek The number of the day within the week (0..6)
*/
DatePickerControl.getDayClass =3D function(vday, dayofweek)
{
var gNow =3D new Date();
var vNowDay =3D gNow.getDate();
var vNowMonth =3D gNow.getMonth();
var vNowYear =3D gNow.getFullYear();

if (vday == vNowDay && this.month == vNowMonth && this.year ==
vNowYear){
return "today";
}
else{
// transform the day acording the specified firts day of week
var realdayofweek =3D (7 + dayofweek + this.firstWeekDay) % 7;
for (i=3D0; i if (realdayofweek == this.weekend[i]){
return "weekend";
}
}
return "day";
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Gets the date string according to calendar's format
* @param p_day The number of the day in the current month and year
*/
DatePickerControl.formatData =3D function(p_day)
{
var vData;
var vMonth =3D 1 + this.month;
vMonth =3D (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
var vMon =3D this.getMonthName(this.month).substr(0,3).toUpperCase();
var vFMon =3D this.getMonthName(this.month).toUpperCase();
var vY4 =3D new String(this.year);
var vY2 =3D new String(this.year).substr(2,2);
var vDD =3D (p_day.toString().length < 2) ? "0" + p_day : p_day;

switch (this.format) {

case "MM/DD/YYYY" :
vData =3D vMonth + "/" + vDD + "/" + vY4;
break;
case "MM/DD/YY" :
vData =3D vMonth + "/" + vDD + "/" + vY2;
break;
case "MM-DD-YYYY" :
vData =3D vMonth + "-" + vDD + "-" + vY4;
break;
case "MM-DD-YY" :
vData =3D vMonth + "-" + vDD + "-" + vY2;
break;
case "YYYY-MM-DD":
vData =3D vY4 + "-" + vMonth + "-" + vDD;
break;
case "YYYY/MM/DD":
vData =3D vY4 + "/" + vMonth + "/" + vDD;
break;

case "DD/MON/YYYY" :
vData =3D vDD + "/" + vMon + "/" + vY4;
break;
case "DD/MON/YY" :
vData =3D vDD + "/" + vMon + "/" + vY2;
break;
case "DD-MON-YYYY" :
vData =3D vDD + "-" + vMon + "-" + vY4;
break;
case "DD-MON-YY" :
vData =3D vDD + "-" + vMon + "-" + vY2;
break;

case "DD/MONTH/YYYY" :
vData =3D vDD + "/" + vFMon + "/" + vY4;
break;
case "DD/MONTH/YY" :
vData =3D vDD + "/" + vFMon + "/" + vY2;
break;
case "DD-MONTH-YYYY" :
vData =3D vDD + "-" + vFMon + "-" + vY4;
break;
case "DD-MONTH-YY" :
vData =3D vDD + "-" + vFMon + "-" + vY2;
break;

case "DD/MM/YYYY" :
vData =3D vDD + "/" + vMonth + "/" + vY4;
break;
case "DD/MM/YY" :
vData =3D vDD + "/" + vMonth + "/" + vY2;
break;
case "DD-MM-YYYY" :
vData =3D vDD + "-" + vMonth + "-" + vY4;
break;
case "DD-MM-YY" :
vData =3D vDD + "-" + vMonth + "-" + vY2;
break;

case "DD.MM.YYYY" :
vData =3D vDD + "." + vMonth + "." + vY4;
break;
case "DD.MM.YY" :
vData =3D vDD + "." + vMonth + "." + vY2;
break;

default :
vData =3D vMonth + "/" + vDD + "/" + vY4;
}

return vData;
}


//---------------------------------------------------------- ---------------=
----
/**
* Try to get the date from the control according to the format:
* This function doesn't work with named months
* @return An object of class Date with the current date in the
control (if succesfull) or
* today if fails.
*/
DatePickerControl.getDateFromControl =3D function(ctrl)
{
if (ctrl == null) ctrl =3D this.inputControl;
var value =3D ctrl.value;
var format =3D ctrl.getAttribute("datepicker_format");
return this.getDateFromString(value, format.toString());
}


//---------------------------------------------------------- ---------------=
----
/**
* Gets a Date objects from a string given a format.
* @param strdate The string with the date.
* @param format The date's format.
* @return A Date object with the date of string according to the
format, or
* today if string is empty or non-valid.
*/
DatePickerControl.getDateFromString =3D function(strdate, format)
{
var aDate =3D new Date();
var day, month, year;

if (strdate == "" || format == "") return aDate;
strdate =3D strdate.replace("/", "@").replace("/", "@");
strdate =3D strdate.replace("-", "@").replace("-", "@");
strdate =3D strdate.replace(".", "@").replace(".", "@");
// check again
if (strdate.indexOf("/")>=3D0 || strdate.indexOf("-")>=3D0 ||
strdate.indexOf(".")>=3D0) return aDate;
// validate all other stuff
var data =3D strdate.split("@");
if (data.length !=3D 3) return aDate;
for (i=3D0; i<3; i++){
data[i] =3D parseFloat(data[i]);
if (isNaN(data[i])) return aDate;
}
if (format.substring(0,1).toUpperCase() == "D"){
aDate.setDate(data[0]);
aDate.setMonth(data[1]-1);
aDate.setFullYear(this.yearTwo2Four(data[2]));
}
else if (format.substring(0,1).toUpperCase() == "Y"){
aDate.setDate(data[2]);
aDate.setMonth(data[1]-1);
aDate.setFullYear(this.yearTwo2Four(data[0]));
}
else if (format.substring(0,1).toUpperCase() == "M"){
aDate.setDate(data[1]);
aDate.setMonth(data[0]-1);
aDate.setFullYear(this.yearTwo2Four(data[2]));
}
return aDate;
}


//---------------------------------------------------------- ---------------=
----
/**
* Transform a two digits year into a four digits year.
* All year from 30 to 99 are trated as 19XX, year before
* 30 are trated as 20XX
*/
DatePickerControl.yearTwo2Four =3D function(year)
{
if (year < 99){
if (year >=3D 30){
year +=3D 1900;
}
else{
year +=3D 2000;
}
}
return year;
}


//---------------------------------------------------------- ---------------=
----
/**
* Writes the specified date in the control and close the calendar.
*/
DatePickerControl.writeDate =3D function(day)
{
var d =3D this.formatData(day);
this.inputControl.value =3D d;
this.originalValue =3D d;
this.hide();
if (DatePickerControl.onSelect)
DatePickerControl.onSelect(this.inputControl.id);
this.firstFocused =3D true;
this.inputControl.focus();
}


//---------------------------------------------------------- ---------------=
----
/**
* Writes the current date in the control
*/
DatePickerControl.writeCurrentDate =3D function()
{
var d =3D this.formatData(this.currentDay);
this.inputControl.value =3D d;
}


//---------------------------------------------------------- ---------------=
----
/**
* Creates and write the calendar's code
* @param m The month to build
* @param y The year to build
*/
DatePickerControl.build =3D function(m, y)
{
var bkm =3D this.month;
var bky =3D this.year;
var calframe =3D document.getElementById(this.calFrameId);
if (m==null){
var now =3D new Date();
this.month =3D now.getMonth();
this.year =3D now.getFullYear();
}
else{
this.month =3D m;
this.year =3D y;
}
// validate range
if (!this.isInRange(null)){
this.month =3D bkm;
this.year =3D bky;
}
if (!this.isInRange(this.currentDay)){
if (this.minDate && this.currentDay < this.minDate.getDate())
this.currentDay =3D this.minDate.getDate();
if (this.maxDate && this.currentDay > this.maxDate.getDate())
this.currentDay =3D this.maxDate.getDate();
}
this.monthName =3D this.Months[this.month];
var code =3D this.getAllCode();
writeLayer(this.calContainer.id, null, code);
if (this.calContainer && calframe) this.calContainer.style.height =3D
calframe.offsetHeight;
this.firstFocused =3D true;
this.inputControl.focus();
this.selectDay(this.currentDay);
}


//---------------------------------------------------------- ---------------=
----
/**
* Build the prev month calendar
*/
DatePickerControl.buildPrev =3D function()
{
if (!this.displayed) return;
var prevMMYYYY =3D this.calcMonthYear(this.month, this.year, -1);
var prevMM =3D prevMMYYYY[0];
var prevYYYY =3D prevMMYYYY[1];
this.build(prevMM, prevYYYY);
}


//---------------------------------------------------------- ---------------=
----
/**
* Build the next month calendar
*/
DatePickerControl.buildNext =3D function()
{
if (!this.displayed) return;
var nextMMYYYY =3D this.calcMonthYear(this.month, this.year, 1);
var nextMM =3D nextMMYYYY[0];
var nextYYYY =3D nextMMYYYY[1];
this.build(nextMM, nextYYYY);
}


//---------------------------------------------------------- ---------------=
----
/**
* Today button action
*/
DatePickerControl.selectToday =3D function()
{
var now =3D new Date();
var today =3D now.getDate();
if (!this.isInRange(today)) return;
if (this.closeOnTodayBtn){
this.currentDay =3D today;
this.writeDate(this.currentDay);
}
else{
this.selectDay(today);
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Select a specific day
*/
DatePickerControl.selectDay =3D function(day)
{
if (!this.displayed) return;
if (!this.isInRange(day)){
return;
}
var n =3D this.currentDay;
var max =3D this.getDaysOfMonth(this.month, this.year);
if (day > max) return;
var newDayObject =3D document.getElementById(this.dayIdPrefix+day);
var currentDayObject =3D document.getElementById(this.dayIdPrefix
+this.currentDay);
if (currentDayObject){
currentDayObject.className =3D
currentDayObject.getAttribute("class_orig");
}
if (newDayObject){
newDayObject.className =3D "current";
this.currentDay =3D day;
this.writeCurrentDate();
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Select the prev week day
* @param decr Use 1 for yesterday or 7 for prev week
*/
DatePickerControl.selectPrevDay =3D function(decr)
{
if (!this.displayed) return;
var n =3D this.currentDay;
var max =3D this.getDaysOfMonth(this.month, this.year);
var prev =3D n - decr;
if ( prev <=3D 0 ){
if (decr == 7){
n =3D (n + this.dayOfWeek) + 28 - this.dayOfWeek;
n--;
prev =3D n > max ? n-7 : n;
}
else{
prev =3D max;
}
}
this.selectDay(prev);
}


//---------------------------------------------------------- ---------------=
----
/**
* Select the next week day
* @param decr Use 1 for tomorrow or 7 for next week
*/
DatePickerControl.selectNextDay =3D function(incr)
{
if (!this.displayed) return;
var n =3D this.currentDay;
var max =3D this.getDaysOfMonth(this.month, this.year);
var next =3D n + incr;
if ( next > max ){
if (incr == 7){
n =3D ((n + this.dayOfWeek) % 7) - this.dayOfWeek;
next =3D n < 0 ? n+7 : n;
next++;
}
else{
next =3D 1;
}
}
this.selectDay(next);
}


//---------------------------------------------------------- ---------------=
----
/**
* Show the calendar for an edit control
*/
DatePickerControl.showForEdit =3D function(edit)
{
if (this.displayed) return;
if (edit == null) return;
if (edit.disabled) return;
this.inputControl =3D edit;
this.originalValue =3D edit.value;
// the format
var format =3D this.inputControl.getAttribute("datepicker_format");
if (format == null) format =3D this.defaultFormat;
this.format =3D format;
// build with the current date in the control?
if (this.validate(edit.value, format)){
var date =3D this.getDateFromControl();
this.currentDate =3D date;
this.build(date.getMonth(), date.getFullYear());
this.currentDay =3D date.getDate();
}
else{
edit.value =3D "";
this.originalValue =3D "";
this.currentDate =3D null;
if (this.defaultTodaySel){
this.currentDay =3D new Date().getDate();
}
else{
this.currentDay =3D 1;
}
this.build(null, null);
}
var currentDayObject =3D document.getElementById(this.dayIdPrefix
+this.currentDay);
if (currentDayObject) currentDayObject.className =3D "current";
this.writeCurrentDate();
// and finally
this.show();
}


//---------------------------------------------------------- ---------------=
----
/**
* Determine if a given day (with current month and year) is in range
* according to the min and max limit.
* @param day The number of the day; if null then the current month is
validated.
*/
DatePickerControl.isInRange =3D function(day)
{
if (!this.minDate && !this.maxDate) return true;
if (day){
var aDate =3D new Date();
aDate.setFullYear(this.year);
aDate.setMonth(this.month);
aDate.setDate(day);
if (this.minDate){
if (this.compareDates(aDate, this.minDate) < 0) return false;
}
if (this.maxDate){
if (this.compareDates(aDate, this.maxDate) > 0) return false;
}
}
else{ // validate only the month.
var currentym =3D parseInt(this.year.toString() + (this.month < 10 ?
"0"+this.month.toString() : this.month.toString()));
var m;
if (this.minDate){
m =3D this.minDate.getMonth();
var minym =3D parseInt(this.minDate.getFullYear().toString() + (m <
10 ? "0"+m.toString() : m.toString()));
if (currentym < minym) return false;
}
if (this.maxDate){
m =3D this.maxDate.getMonth();
var maxym =3D parseInt(this.maxDate.getFullYear().toString() + (m <
10 ? "0"+m.toString() : m.toString()));
if (currentym > maxym) return false;
}
}
return true;
}


//---------------------------------------------------------- ---------------=
----
/**
* Compare two dates. We cannot use Date getTime() mehtod in some
specific cases,
* so we use a trick with the string year+month+day transformed in a
number.
* @return '<0' if d1 < d2 '0' if d1 =3D d2 '>0' if d1 > d2
*/
DatePickerControl.compareDates =3D function(d1, d2)
{
var m =3D d1.getMonth();
var d =3D d1.getDate();
var s1 =3D d1.getFullYear().toString() + (m<10 ? "0"+m.toString() :
mtoString()) + (d<10 ? "0"+d.toString() : d.toString());
m =3D d2.getMonth();
d =3D d2.getDate();
var s2 =3D d2.getFullYear().toString() + (m<10 ? "0"+m.toString() :
mtoString()) + (d<10 ? "0"+d.toString() : d.toString());
var n1 =3D parseInt(s1);
var n2 =3D parseInt(s2);
return n1-n2;
}


//---------------------------------------------------------- ---------------=
----
/**
* Validate a string according to a date format.
* Portions of code from: http://www.rgagnon.com/jsdetails/js-0063.html
* @param strdate The string with the date.
* @param format The format to validate.
* @return true if succesfull or false otherwise
*/
DatePickerControl.validate =3D function(strdate, format)
{
var dateRegExp;
var separator;
var d, m, y;
var od =3D this.currentDay, om =3D this.month, oy =3D this.year;

if (strdate == "") return false;

// use the correct regular expresion...
if (format.substring(0,1).toUpperCase() == "D"){
dateRegExp =3D /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2,4}$/
}
else if (format.substring(0,1).toUpperCase() == "Y"){
dateRegExp =3D /^\d{2,4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
}
else if (format.substring(0,1).toUpperCase() == "M"){
dateRegExp =3D /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2,4}$/
}

// is ok at least with the format?
if (!dateRegExp.test(strdate)){
return false;
}

// chek for a valid day month day combination
separator =3D (strdate.indexOf("/") > 1) ? "/" : ((strdate.indexOf("-")
> 1) ? "-" : ".");
var datearray =3D strdate.split(separator);

// get the number of date elements
if (format.substring(0,1).toUpperCase() == "D"){
d =3D parseFloat(datearray[0]);
m =3D parseFloat(datearray[1]);
y =3D parseFloat(datearray[2]);
}
else if (format.substring(0,1).toUpperCase() == "Y"){
d =3D parseFloat(datearray[2]);
m =3D parseFloat(datearray[1]);
y =3D parseFloat(datearray[0]);
}
else if (format.substring(0,1).toUpperCase() == "M"){
d =3D parseFloat(datearray[1]);
m =3D parseFloat(datearray[0]);
y =3D parseFloat(datearray[2]);
}
// is a valid month?
if (m<1 || m>12) return false;
//check if month value and day value agree
if (d > this.getDaysOfMonth(m-1)) return false;

// ok, date is valid... but is it in range?
this.month =3D m;
this.year =3D y;
var res =3D this.isInRange(d);
this.month =3D om;
this.year =3D oy;
return res;
}


//---------------------------------------------------------- ---------------=
----
/**
* Check if a year is leap:
* 1.Years evenly divisible by four are normally leap years, except
for...
* 2.Years also evenly divisible by 100 are not leap years, except
for...
* 3.Years also evenly divisible by 400 are leap years.
* @return true if the year is leap or false otherwise.
*/
DatePickerControl.isLeapYear =3D function(year)
{
if ((year % 4) == 0){
if ((year % 100) == 0 && (year % 400) !=3D 0){
return false;
}
return true;
}
return false;
}


//---------------------------------------------------------- ---------------=
----
/**
* Click event for calendar button
*/
function DPC_onButtonClick(event)
{DatePickerControl.onButtonClick(event);}
DatePickerControl.onButtonClick =3D function(event)
{
if (!this.displayed){
// get the button
if (event == null) event =3D window.event;
var button =3D (event.srcElement) ? event.srcElement :
event.originalTarget;
// gets the associated input:
var input =3D
document.getElementById(button.getAttribute("datepicker_inpu tid"));
this.showForEdit(input);
}
else{
this.hide();
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Click event for calendar layer.
*/
function DPC_onContainerClick(event)
{DatePickerControl.onContainerClick(event);}
DatePickerControl.onContainerClick =3D function(event)
{
if (event == null) event =3D window.event;
if (this.hideTimeout){
clearTimeout(this.hideTimeout);
this.hideTimeout =3D null;
}
this.inputControl.focus();
return false;
}


//---------------------------------------------------------- ---------------=
----
/**
* Key-up event for edit controls as date-pickers
*/
function DPC_onEditControlKeyUp(event)
{DatePickerControl.onEditControlKeyUp(event);}
DatePickerControl.onEditControlKeyUp =3D function(event)
{
if (event == null) event =3D window.event;
var edit =3D event.srcElement ? event.srcElement :
event.originalTarget;
var kc =3D event.charCode ? event.charCode : event.which ?
event.which : event.keyCode;
//alert(event.keyCode);
switch (kc){
case 37: // left arrow key
this.selectPrevDay(1);
break;

case 38: // up arrow key
this.selectPrevDay(7);
break;

case 39: // right arrow key
this.selectNextDay(1);
break;

case 40: // down arrow key
if (!this.displayed){
this.showForEdit(edit);
}
else{
this.selectNextDay(7);
break;
}
break;

case 27: // escape key
this.hide();
break;

case 33: // repag key
if ((event.modifiers & Event.SHIFT_MASK) || (event.shiftKey)){
this.build(this.month, parseInt(this.year)-1);
}
else{
this.buildPrev();
}
break;

case 34: // avpag key
if ((event.modifiers & Event.SHIFT_MASK) || (event.shiftKey)){
this.build(this.month, parseInt(this.year)+1);
}
else{
this.buildNext();
}
break;

case 13: // enter-key (forms without submit buttons)
if (this.displayed && this.currentDay > 0 && this.submitByKey){
this.writeDate(this.currentDay);
}
break;
}
return false;
}


//---------------------------------------------------------- ---------------=
----
/**
* Key-down event for edit controls as date-pickers
*/
function DPC_onEditControlKeyDown(event)
{DatePickerControl.onEditControlKeyDown(event);}
DatePickerControl.onEditControlKeyDown =3D function(event)
{
if (event == null) event =3D window.event;
var edit =3D event.srcElement ? event.srcElement :
event.originalTarget;
var kc =3D event.charCode ? event.charCode : event.which ?
event.which : event.keyCode;
//alert(event.keyCode);
if ( kc >=3D 65 && kc <=3D 90 ){ // letters
if (event.stopPropagation) event.stopPropagation();
if (event.preventDefault) event.preventDefault();
event.returnValue =3D false;
event.cancelBubble =3D true;
return false;
}
switch (kc){
case 13: // enter key
this.submitByKey =3D true;
break;
case 9: // tab key
case 32: // space-bar key
if (this.displayed && this.currentDay > 0){
this.writeDate(this.currentDay);
}
break;
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Key-press event for edit controls as date-pickers
*/
function DPC_onEditControlKeyPress(event)
{DatePickerControl.onEditControlKeyPress(event);}
DatePickerControl.onEditControlKeyPress =3D function(event)
{
if (event == null) event =3D window.event;
var edit =3D event.srcElement ? event.srcElement :
event.originalTarget;
var kc =3D event.charCode ? event.charCode : event.which ?
event.which : event.keyCode;
if (!((kc < 32) || (kc > 44 && kc < 58))){
if (event.stopPropagation) event.stopPropagation();
if (event.preventDefault) event.preventDefault();
event.returnValue =3D false;
event.cancelBubble =3D true;
return false;
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Blur event for edit controls as date-pickers
*/
function DPC_onEditControlBlur(event)
{DatePickerControl.onEditControlBlur(event);}
DatePickerControl.onEditControlBlur =3D function(event)
{
if (event == null) event =3D window.event;
if (!this.hideTimeout){
this.hideTimeout =3D setTimeout("DatePickerControl.hide()",
this.HIDE_TIMEOUT);
}
this.firstFocused =3D false;
this.hideCauseBlur =3D true;
}


//---------------------------------------------------------- ---------------=
----
/**
* Change event for edit controls as date-pickers
*/
function DPC_onEditControlChange(event)
{DatePickerControl.onEditControlChange(event);}
DatePickerControl.onEditControlChange =3D function(event)
{
if (event == null) event =3D window.event;
var edit =3D (event.srcElement) ? event.srcElement :
event.originalTarget;
if (edit.value == "") return;
var format =3D edit.getAttribute("datepicker_format");
if (!this.validate(edit.value, format)){
setTimeout("e =3D document.getElementById('"+edit.id+"'); e.value=3D'';
efocus()", 10);
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Focus event for edit controls as date-pickers
*/
function DPC_onEditControlFocus(event)
{DatePickerControl.onEditControlFocus(event);}
DatePickerControl.onEditControlFocus =3D function(event)
{
if (event == null) event =3D window.event;
var edit =3D (event.srcElement) ? event.srcElement :
event.originalTarget;

// get the date range
var format =3D edit.getAttribute("datepicker_format");
var min =3D edit.getAttribute("datepicker_min");
this.minDate =3D min ? this.getDateFromString(min, format) : null;
var max =3D edit.getAttribute("datepicker_max");
this.maxDate =3D max ? this.getDateFromString(max, format) : null;
if (this.maxDate && this.minDate){
if (this.maxDate.getTime() < this.minDate.getTime()){
var tmp =3D this.maxDate;
this.maxDate =3D this.minDate;
this.minDate =3D tmp;
}
}

if ((!this.displayed || this.hideCauseBlur) && this.autoShow && !
this.firstFocused){
clearTimeout(this.hideTimeout);
this.hideTimeout =3D null;
this.firstFocused =3D true;
if (this.hideCauseBlur){
this.hideCauseBlur =3D false;
this.hide();
}
this.showForEdit(edit);
}
else if (this.inputControl && this.inputControl.id !=3D edit.id){
this.hide();
}
else if (this.hideTimeout){
clearTimeout(this.hideTimeout);
this.hideTimeout =3D null;
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Form's submit event
*/
function DPC_onFormSubmit(event)
{DatePickerControl.onFormSubmit(event);}
DatePickerControl.onFormSubmit =3D function(event)
{
if (this.submitByKey){
this.submitByKey =3D false;
if (this.displayed && this.currentDay > 0){
this.writeDate(this.currentDay);
if (event == null) event =3D window.event;
var theForm =3D (event.srcElement) ? event.srcElement :
event.originalTarget;
if (event.stopPropagation) event.stopPropagation();
if (event.preventDefault) event.preventDefault();
event.returnValue =3D false;
event.cancelBubble =3D true;
return false;
}
}
this.reformatOnSubmit();
}


//---------------------------------------------------------- ---------------=
----
/**
* Reformat all dates to the current onSubmit date format
*/
DatePickerControl.reformatOnSubmit =3D function()
{
if (this.submitFormat == "") return true;
var inputControls =3D document.getElementsByTagName("input");
var inputsLength =3D inputControls.length;
var i;
for (i=3D0; i if (inputControls[i].type.toLowerCase() == "text"){
var editctrl =3D inputControls[i];
if (editctrl.value == "") continue;
var isdpc =3D editctrl.getAttribute("isdatepicker");
if (isdpc && isdpc == "true"){
var thedate =3D this.getDateFromControl(editctrl);
var res =3D this.submitFormat.replace("DD", thedate.getDate());
var mo =3D thedate.getMonth() + 1;
res =3D res.replace("MM", mo.toString());
if (this.submitFormat.indexOf("YYYY") >=3D 0){
res =3D res.replace("YYYY", thedate.getFullYear());
}
else{
res =3D res.replace("YY", thedate.getFullYear());
}
editctrl.value =3D res;
}
}
}
return true;
}


//---------------------------------------------------------- ---------------=
----
/**
* Replacement for submit method of the form.
*/
function DPC_formSubmit()
{
var res =3D DatePickerControl.reformatOnSubmit();
if (this.submitOrig){
res =3D this.submitOrig();
}
return res;
}


//---------------------------------------------------------- ---------------=
----
/**
* Window resize event.
*/
function DPC_onWindowResize(event)
{DatePickerControl.onWindowResize(event);}
DatePickerControl.onWindowResize =3D function(event)
{
this.relocate();
this.relocateButtons();
}


//---------------------------------------------------------- ---------------=
----
/**
* Relocate buttons
*/
DatePickerControl.relocateButtons =3D function()
{
var divElements =3D document.getElementsByTagName("div");
for (key in divElements){
if (divElements[key].id &&
divElements[key].id.indexOf(this.buttonIdPrefix) == 0){
var calButton =3D divElements[key];
if (calButton.style.display == 'none') continue;
var input =3D
document.getElementById(calButton.getAttribute("datepicker_i nputid"));
if (input.style.display == 'none' || input.offsetTop == 0)
continue;
var nTop =3D getObject.getSize("offsetTop", input);
var nLeft =3D getObject.getSize("offsetLeft", input);
calButton.style.top =3D (nTop + Math.floor((input.offsetHeight-
calButton.offsetHeight)/2) + this.buttonOffsetY) + "px";
var btnOffX =3D Math.floor((input.offsetHeight -
calButton.offsetHeight) / 2);
if (this.buttonPosition == "in"){
calButton.style.left =3D (nLeft + input.offsetWidth -
calButton.offsetWidth - btnOffX + this.buttonOffsetX) + "px";
}
else{ // "out"
calButton.style.left =3D (nLeft + input.offsetWidth + btnOffX +
this.buttonOffsetX) + "px";
}
}
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Relocate the calendar's frame
*/
DatePickerControl.relocate =3D function()
{
if (this.displayed){
var input =3D this.inputControl;
if (input == null) return;
var top =3D getObject.getSize("offsetTop", input);
var left =3D getObject.getSize("offsetLeft", input);
this.calContainer.style.top =3D top + input.offsetHeight +
this.offsetY + "px";
this.calContainer.style.left =3D left + this.offsetX + "px";
if (this.calBG){ // the ugly patch for IE
this.calBG.style.top =3D this.calContainer.style.top;
this.calBG.style.left =3D this.calContainer.style.left;
}
}
}


//---------------------------------------------------------- ---------------=
----
/**
* Gets the number of the week on the year for the given year, month,
day.
*/
DatePickerControl.getWeekNumber =3D function(year, month, day)
{
var when =3D new Date(year,month,day);
var newYear =3D new Date(year,0,1);
var offset =3D 7 + 1 - newYear.getDay();
if (offset == 8) offset =3D 1;
var daynum =3D ((Date.UTC(y2k(year),when.getMonth(),when.getDate(),
0,0,0) - Date.UTC(y2k(year),0,1,0,0,0)) /1000/60/60/24) + 1;
var weeknum =3D Math.floor((daynum-offset+7)/7);
if (weeknum == 0) {
year--;
var prevNewYear =3D new Date(year,0,1);
var prevOffset =3D 7 + 1 - prevNewYear.getDay();
if (prevOffset == 2 || prevOffset == 8) weeknum =3D 53; else week=
num =3D
52;
}
return weeknum;
}

function y2k(number) { return (number < 1000) ? number + 1900 :
number; }


//---------------------------------------------------------- ---------------=
----
// Following 2 functions by: Mircho Mirev

function getObject(sId)
{
if (bw.dom){
this.hElement =3D document.getElementById(sId);
this.hStyle =3D this.hElement.style;
}
else if (bw.ns4){
this.hElement =3D document.layers[sId];
this.hStyle =3D this.hElement;
}
else if (bw.ie){
this.hElement =3D document.all[sId];
this.hStyle =3D this.hElement.style;
}
}

getObject.getSize =3D function(sParam, hLayer)
{
nPos =3D 0;
while ((hLayer.tagName) && !( /(body|html)/i.test(hLayer.tagName))){
nPos +=3D eval('hLayer.' + sParam);
if (sParam == 'offsetTop'){
if (hLayer.clientTop){
nPos +=3D hLayer.clientTop;
}
}
if (sParam == 'offsetLeft'){
if (hLayer.clientLeft){
nPos +=3D hLayer.clientLeft;
}
}
hLayer =3D hLayer.offsetParent;
}
return nPos;
}


//---------------------------------------------------------- ---------------=
----
/**
* Based on code by: Peter Todorov
*/
function writeLayer(ID, parentID, sText)
{
if (document.layers){
var oLayer;
if(parentID){
oLayer =3D eval('document.' + parentID + '.document.' + ID +
'document');
}
else{
oLayer =3D document.layers[ID].document;
}
oLayer.open();
oLayer.write(sText);
oLayer.close();
}
else if(document.all){
document.all[ID].innerHTML =3D sText;
}
else{
document.getElementById(ID).innerHTML =3D sText;
}
}

//
// Compartir es la =FAnica manera de perdurar
// EOF

Re: Problem with submitting multiple hidden forms

am 01.10.2007 15:22:43 von petersprc

Hi,

With your submit button in the same form as your inputs, it should
work. You can move



In place of



HTH,

John Peters

On Oct 1, 7:27 am, esedic wrote:
> Hi!
>
> I'm novice with php language and I need help.
>
> I'm trying to put together a simple page with html forms in it, the
> submitted values would be written in MySQL database using the
> insert.php file