DateTime Picker

Κώδικας, πληροφορίες, ερωτήσεις και απαντήσεις σχετικές με την JavaScript.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 28 Νοέμ 2008 16:09

Εχω ενα ετοιμο σκριπτακι, για επιλογη ημερομηνιας γεννησης σε μια φορμα εγγραφης μου.

Και χρησιμοποιω το παρακατω html στη φορμα.

Κώδικας: Επιλογή όλων

<label for="Birthdate">Birthdate&#58;</label> <input type="text" id="Birthdate" size="25"><a href="javascript&#58;NewCal&#40;'Birthdate','MMddyyyy'&#41;"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>

Γιατι δεν γινεται εισαγωγη στη ΒΔ μου , ενω το πεδιο ειναι DATETIME ;

Αναθεση τιμης :

$birth = mysql_real_escape_string($_POST['Birthdate']);



( Μαλλον χρειαζεται μεταφορα το τοπικ )
Τελευταία επεξεργασία από το μέλος loxy την 29 Νοέμ 2008 22:59, έχει επεξεργασθεί 1 φορά συνολικά.

Άβαταρ μέλους
fafos
Script Master
Δημοσιεύσεις: 6230
Εγγραφή: 30 Νοέμ 2004 03:09

DateTime Picker

Δημοσίευση από fafos » 28 Νοέμ 2008 16:39

Den tha eprepe na exei kai kapoio name to input? (name="Birthdate")

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 29 Νοέμ 2008 14:56

Εβαλα αλλα παλι δεν...

Άβαταρ μέλους
fafos
Script Master
Δημοσιεύσεις: 6230
Εγγραφή: 30 Νοέμ 2004 03:09

DateTime Picker

Δημοσίευση από fafos » 29 Νοέμ 2008 17:59

loxy έγραψε:Εβαλα αλλα παλι δεν...
prepei na doume olous tous kodikes gia na katalavoume...

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 29 Νοέμ 2008 19:23

Εισαι σιγουρος ; :lol:

Ξεκιναω λοιπον,

κωδικας του σκριπτ...

Κώδικας: Επιλογή όλων

//Javascript name&#58; My Date Time Picker
//Date created&#58; 16-Nov-2003 23&#58;19
//Scripter&#58; TengYong Ng
//Website&#58; http&#58;//www.rainforestnet.com
//Copyright &#40;c&#41; 2003 TengYong Ng
//FileName&#58; DateTimePicker.js
//Version&#58; 0.8
//Contact&#58; contact@rainforestnet.com
// Note&#58; Permission given to use this script in ANY kind of applications if
//       header lines are left unchanged.

//Global variables
var winCal;
var dtToday=new Date&#40;&#41;;
var Cal;
var docCal;
var MonthName=&#91;"January", "February", "March", "April", "May", "June","July", 
	"August", "September", "October", "November", "December"&#93;;
var WeekDayName=&#91;"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"&#93;;	
var exDateTime;//Existing Date and Time

//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="DateTime Picker";//Date Time Picker title.
var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="/";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24

var ShowLongMonth=true;//Show long month name in Calendar header. example&#58; "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var TodayColor="#FFFF33";//Background color of today.
var SelDateColor="#FFFF99";//Backgrond color of selected date in textbox.
var YrSelColor="#cc0033";//color of font of Year selector.
var ThemeBg="";//Background image of Calendar window.
//end Configurable parameters
//end Global variable

function NewCal&#40;pCtrl,pFormat,pShowTime,pTimeMode&#41;
&#123;
	Cal=new Calendar&#40;dtToday&#41;;
	if &#40;&#40;pShowTime!=null&#41; && &#40;pShowTime&#41;&#41;
	&#123;
		Cal.ShowTime=true;
		if &#40;&#40;pTimeMode!=null&#41; &&&#40;&#40;pTimeMode=='12'&#41;||&#40;pTimeMode=='24'&#41;&#41;&#41;
		&#123;
			TimeMode=pTimeMode;
		&#125;		
	&#125;	
	if &#40;pCtrl!=null&#41;
		Cal.Ctrl=pCtrl;
	if &#40;pFormat!=null&#41;
		Cal.Format=pFormat.toUpperCase&#40;&#41;;
	
	exDateTime=document.getElementById&#40;pCtrl&#41;.value;
	if &#40;exDateTime!=""&#41;//Parse Date String
	&#123;
		var Sp1;//Index of Date Separator 1
		var Sp2;//Index of Date Separator 2 
		var tSp1;//Index of Time Separator 1
		var tSp1;//Index of Time Separator 2
		var strMonth;
		var strDate;
		var strYear;
		var intMonth;
		var YearPattern;
		var strHour;
		var strMinute;
		var strSecond;
		//parse month
		Sp1=exDateTime.indexOf&#40;DateSeparator,0&#41;
		Sp2=exDateTime.indexOf&#40;DateSeparator,&#40;parseInt&#40;Sp1&#41;+1&#41;&#41;;
		
		if &#40;&#40;Cal.Format.toUpperCase&#40;&#41;=="DDMMYYYY"&#41; || &#40;Cal.Format.toUpperCase&#40;&#41;=="DDMMMYYYY"&#41;&#41;
		&#123;
			strMonth=exDateTime.substring&#40;Sp1+1,Sp2&#41;;
			strDate=exDateTime.substring&#40;0,Sp1&#41;;
		&#125;
		else if &#40;&#40;Cal.Format.toUpperCase&#40;&#41;=="MMDDYYYY"&#41; || &#40;Cal.Format.toUpperCase&#40;&#41;=="MMMDDYYYY"&#41;&#41;
		&#123;
			strMonth=exDateTime.substring&#40;0,Sp1&#41;;
			strDate=exDateTime.substring&#40;Sp1+1,Sp2&#41;;
		&#125;
		if &#40;isNaN&#40;strMonth&#41;&#41;
			intMonth=Cal.GetMonthIndex&#40;strMonth&#41;;
		else
			intMonth=parseInt&#40;strMonth,10&#41;-1;	
		if &#40;&#40;parseInt&#40;intMonth,10&#41;>=0&#41; && &#40;parseInt&#40;intMonth,10&#41;<12&#41;&#41;
			Cal.Month=intMonth;
		//end parse month
		//parse Date
		if &#40;&#40;parseInt&#40;strDate,10&#41;<=Cal.GetMonDays&#40;&#41;&#41; && &#40;parseInt&#40;strDate,10&#41;>=1&#41;&#41;
			Cal.Date=strDate;
		//end parse Date
		//parse year
		strYear=exDateTime.substring&#40;Sp2+1,Sp2+5&#41;;
		YearPattern=/^\d&#123;4&#125;$/;
		if &#40;YearPattern.test&#40;strYear&#41;&#41;
			Cal.Year=parseInt&#40;strYear,10&#41;;
		//end parse year
		//parse time
		if &#40;Cal.ShowTime==true&#41;
		&#123;
			tSp1=exDateTime.indexOf&#40;"&#58;",0&#41;
			tSp2=exDateTime.indexOf&#40;"&#58;",&#40;parseInt&#40;tSp1&#41;+1&#41;&#41;;
			strHour=exDateTime.substring&#40;tSp1,&#40;tSp1&#41;-2&#41;;
			Cal.SetHour&#40;strHour&#41;;
			strMinute=exDateTime.substring&#40;tSp1+1,tSp2&#41;;
			Cal.SetMinute&#40;strMinute&#41;;
			strSecond=exDateTime.substring&#40;tSp2+1,tSp2+3&#41;;
			Cal.SetSecond&#40;strSecond&#41;;
		&#125;	
	&#125;
	winCal=window.open&#40;"","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft&#41;;
	docCal=winCal.document;
	RenderCal&#40;&#41;;
&#125;

function RenderCal&#40;&#41;
&#123;
	var vCalHeader;
	var vCalData;
	var vCalTime;
	var i;
	var j;
	var SelectStr;
	var vDayCount=0;
	var vFirstDay;

	docCal.open&#40;&#41;;
	docCal.writeln&#40;"<html><head><title>"+WindowTitle+"</title>"&#41;;
	docCal.writeln&#40;"<script>var winMain=window.opener;</script>"&#41;;
	docCal.writeln&#40;"</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>"&#41;;

	vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
	//Month Selector
	vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
	vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript&#58;winMain.Cal.SwitchMth&#40;this.selectedIndex&#41;;winMain.RenderCal&#40;&#41;;\">\n";
	for &#40;i=0;i<12;i++&#41;
	&#123;
		if &#40;i==Cal.Month&#41;
			SelectStr="Selected";
		else
			SelectStr="";	
		vCalHeader+="<option "+SelectStr+" value >"+MonthName&#91;i&#93;+"\n";
	&#125;
	vCalHeader+="</select></td>";
	//Year selector
	vCalHeader+="\n<td align='right'><a href=\"javascript&#58;winMain.Cal.DecYear&#40;&#41;;winMain.RenderCal&#40;&#41;\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript&#58;winMain.Cal.IncYear&#40;&#41;;winMain.RenderCal&#40;&#41;\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";	
	vCalHeader+="</tr>";
	//Calendar header shows Month and Year
	if &#40;ShowMonthYear&#41;
		vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center' color='"+MonthYearColor+"'><b>"+Cal.GetMonthName&#40;ShowLongMonth&#41;+" "+Cal.Year+"</b></font></td></tr>\n";
	//Week day header
	vCalHeader+="<tr bgcolor="+WeekHeadColor+">";
	for &#40;i=0;i<7;i++&#41;
	&#123;
		vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName&#91;i&#93;.substr&#40;0,WeekChar&#41;+"</font></td>";
	&#125;
	vCalHeader+="</tr>";	
	docCal.write&#40;vCalHeader&#41;;
	
	//Calendar detail
	CalDate=new Date&#40;Cal.Year,Cal.Month&#41;;
	CalDate.setDate&#40;1&#41;;
	vFirstDay=CalDate.getDay&#40;&#41;;
	vCalData="<tr>";
	for &#40;i=0;i<vFirstDay;i++&#41;
	&#123;
		vCalData=vCalData+GenCell&#40;&#41;;
		vDayCount=vDayCount+1;
	&#125;
	for &#40;j=1;j<=Cal.GetMonDays&#40;&#41;;j++&#41;
	&#123;
		var strCell;
		vDayCount=vDayCount+1;
		if &#40;&#40;j==dtToday.getDate&#40;&#41;&#41;&&&#40;Cal.Month==dtToday.getMonth&#40;&#41;&#41;&&&#40;Cal.Year==dtToday.getFullYear&#40;&#41;&#41;&#41;
			strCell=GenCell&#40;j,true,TodayColor&#41;;//Highlight today's date
		else
		&#123;
			if &#40;j==Cal.Date&#41;
			&#123;
				strCell=GenCell&#40;j,true,SelDateColor&#41;;
			&#125;
			else
			&#123;	 
				if &#40;vDayCount%7==0&#41;
					strCell=GenCell&#40;j,false,SaturdayColor&#41;;
				else if &#40;&#40;vDayCount+6&#41;%7==0&#41;
					strCell=GenCell&#40;j,false,SundayColor&#41;;
				else
					strCell=GenCell&#40;j,null,WeekDayColor&#41;;
			&#125;		
		&#125;						
		vCalData=vCalData+strCell;

		if&#40;&#40;vDayCount%7==0&#41;&&&#40;j<Cal.GetMonDays&#40;&#41;&#41;&#41;
		&#123;
			vCalData=vCalData+"</tr>\n<tr>";
		&#125;
	&#125;
	docCal.writeln&#40;vCalData&#41;;	
	//Time picker
	if &#40;Cal.ShowTime&#41;
	&#123;
		var showHour;
		showHour=Cal.getShowHour&#40;&#41;;		
		vCalTime="<tr>\n<td colspan='7' align='center'>";
		vCalTime+="<input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH&#58; 22px\" value="+showHour+" onchange=\"javascript&#58;winMain.Cal.SetHour&#40;this.value&#41;\">";
		vCalTime+=" &#58; ";
		vCalTime+="<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH&#58; 22px\" value="+Cal.Minutes+" onchange=\"javascript&#58;winMain.Cal.SetMinute&#40;this.value&#41;\">";
		vCalTime+=" &#58; ";
		vCalTime+="<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH&#58; 22px\" value="+Cal.Seconds+" onchange=\"javascript&#58;winMain.Cal.SetSecond&#40;this.value&#41;\">";
		if &#40;TimeMode==12&#41;
		&#123;
			var SelectAm =&#40;parseInt&#40;Cal.Hours,10&#41;<12&#41;? "Selected"&#58;"";
			var SelectPm =&#40;parseInt&#40;Cal.Hours,10&#41;>=12&#41;? "Selected"&#58;"";

			vCalTime+="<select name=\"ampm\" onchange=\"javascript&#58;winMain.Cal.SetAmPm&#40;this.options&#91;this.selectedIndex&#93;.value&#41;;\">";
			vCalTime+="<option "+SelectAm+" value=\"AM\">AM</option>";
			vCalTime+="<option "+SelectPm+" value=\"PM\">PM<option>";
			vCalTime+="</select>";
		&#125;	
		vCalTime+="\n</td>\n</tr>";
		docCal.write&#40;vCalTime&#41;;
	&#125;	
	//end time picker
	docCal.writeln&#40;"\n</table>"&#41;;
	docCal.writeln&#40;"</form></body></html>"&#41;;
	docCal.close&#40;&#41;;
&#125;

function GenCell&#40;pValue,pHighLight,pColor&#41;//Generate table cell with value
&#123;
	var PValue;
	var PCellStr;
	var vColor;
	var vHLstr1;//HighLight string
	var vHlstr2;
	var vTimeStr;
	
	if &#40;pValue==null&#41;
		PValue="";
	else
		PValue=pValue;
	
	if &#40;pColor!=null&#41;
		vColor="bgcolor=\""+pColor+"\"";
	else
		vColor="";	
	if &#40;&#40;pHighLight!=null&#41;&&&#40;pHighLight&#41;&#41;
		&#123;vHLstr1="color='red'><b>";vHLstr2="</b>";&#125;
	else
		&#123;vHLstr1=">";vHLstr2="";&#125;	
	
	if &#40;Cal.ShowTime&#41;
	&#123;
		vTimeStr="winMain.document.getElementById&#40;'"+Cal.Ctrl+"'&#41;.value+=' '+"+"winMain.Cal.getShowHour&#40;&#41;"+"+'&#58;'+"+"winMain.Cal.Minutes"+"+'&#58;'+"+"winMain.Cal.Seconds";
		if &#40;TimeMode==12&#41;
			vTimeStr+="+' '+winMain.Cal.AMorPM";
	&#125;	
	else
		vTimeStr="";		
	PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript&#58;winMain.document.getElementById&#40;'"+Cal.Ctrl+"'&#41;.value='"+Cal.FormatDate&#40;PValue&#41;+"';"+vTimeStr+";window.close&#40;&#41;;\">"+PValue+"</a>"+vHLstr2+"</font></td>";
	return PCellStr;
&#125;

function Calendar&#40;pDate,pCtrl&#41;
&#123;
	//Properties
	this.Date=pDate.getDate&#40;&#41;;//selected date
	this.Month=pDate.getMonth&#40;&#41;;//selected month number
	this.Year=pDate.getFullYear&#40;&#41;;//selected year in 4 digits
	this.Hours=pDate.getHours&#40;&#41;;	
	
	if &#40;pDate.getMinutes&#40;&#41;<10&#41;
		this.Minutes="0"+pDate.getMinutes&#40;&#41;;
	else
		this.Minutes=pDate.getMinutes&#40;&#41;;
	
	if &#40;pDate.getSeconds&#40;&#41;<10&#41;
		this.Seconds="0"+pDate.getSeconds&#40;&#41;;
	else		
		this.Seconds=pDate.getSeconds&#40;&#41;;
		
	this.MyWindow=winCal;
	this.Ctrl=pCtrl;
	this.Format="ddMMyyyy";
	this.Separator=DateSeparator;
	this.ShowTime=false;
	if &#40;pDate.getHours&#40;&#41;<12&#41;
		this.AMorPM="AM";
	else
		this.AMorPM="PM";	
&#125;

function GetMonthIndex&#40;shortMonthName&#41;
&#123;
	for &#40;i=0;i<12;i++&#41;
	&#123;
		if &#40;MonthName&#91;i&#93;.substring&#40;0,3&#41;.toUpperCase&#40;&#41;==shortMonthName.toUpperCase&#40;&#41;&#41;
		&#123;	return i;&#125;
	&#125;
&#125;
Calendar.prototype.GetMonthIndex=GetMonthIndex;

function IncYear&#40;&#41;
&#123;	Cal.Year++;&#125;
Calendar.prototype.IncYear=IncYear;

function DecYear&#40;&#41;
&#123;	Cal.Year--;&#125;
Calendar.prototype.DecYear=DecYear;
	
function SwitchMth&#40;intMth&#41;
&#123;	Cal.Month=intMth;&#125;
Calendar.prototype.SwitchMth=SwitchMth;

function SetHour&#40;intHour&#41;
&#123;	
	var MaxHour;
	var MinHour;
	if &#40;TimeMode==24&#41;
	&#123;	MaxHour=23;MinHour=0&#125;
	else if &#40;TimeMode==12&#41;
	&#123;	MaxHour=12;MinHour=1&#125;
	else
		alert&#40;"TimeMode can only be 12 or 24"&#41;;		
	var HourExp=new RegExp&#40;"^\\d\\d$"&#41;;
	if &#40;HourExp.test&#40;intHour&#41; && &#40;parseInt&#40;intHour,10&#41;<=MaxHour&#41; && &#40;parseInt&#40;intHour,10&#41;>=MinHour&#41;&#41;
	&#123;	
		if &#40;&#40;TimeMode==12&#41; && &#40;Cal.AMorPM=="PM"&#41;&#41;
		&#123;
			if &#40;parseInt&#40;intHour,10&#41;==12&#41;
				Cal.Hours=12;
			else	
				Cal.Hours=parseInt&#40;intHour,10&#41;+12;
		&#125;	
		else if &#40;&#40;TimeMode==12&#41; && &#40;Cal.AMorPM=="AM"&#41;&#41;
		&#123;
			if &#40;intHour==12&#41;
				intHour-=12;
			Cal.Hours=parseInt&#40;intHour,10&#41;;
		&#125;
		else if &#40;TimeMode==24&#41;
			Cal.Hours=parseInt&#40;intHour,10&#41;;	
	&#125;
&#125;
Calendar.prototype.SetHour=SetHour;

function SetMinute&#40;intMin&#41;
&#123;
	var MinExp=new RegExp&#40;"^\\d\\d$"&#41;;
	if &#40;MinExp.test&#40;intMin&#41; && &#40;intMin<60&#41;&#41;
		Cal.Minutes=intMin;
&#125;
Calendar.prototype.SetMinute=SetMinute;

function SetSecond&#40;intSec&#41;
&#123;	
	var SecExp=new RegExp&#40;"^\\d\\d$"&#41;;
	if &#40;SecExp.test&#40;intSec&#41; && &#40;intSec<60&#41;&#41;
		Cal.Seconds=intSec;
&#125;
Calendar.prototype.SetSecond=SetSecond;

function SetAmPm&#40;pvalue&#41;
&#123;
	this.AMorPM=pvalue;
	if &#40;pvalue=="PM"&#41;
	&#123;
		this.Hours=&#40;parseInt&#40;this.Hours,10&#41;&#41;+12;
		if &#40;this.Hours==24&#41;
			this.Hours=12;
	&#125;	
	else if &#40;pvalue=="AM"&#41;
		this.Hours-=12;	
&#125;
Calendar.prototype.SetAmPm=SetAmPm;

function getShowHour&#40;&#41;
&#123;
	var finalHour;
    if &#40;TimeMode==12&#41;
    &#123;
    	if &#40;parseInt&#40;this.Hours,10&#41;==0&#41;
		&#123;
			this.AMorPM="AM";
			finalHour=parseInt&#40;this.Hours,10&#41;+12;	
		&#125;
		else if &#40;parseInt&#40;this.Hours,10&#41;==12&#41;
		&#123;
			this.AMorPM="PM";
			finalHour=12;
		&#125;		
		else if &#40;this.Hours>12&#41;
		&#123;
			this.AMorPM="PM";
			if &#40;&#40;this.Hours-12&#41;<10&#41;
				finalHour="0"+&#40;&#40;parseInt&#40;this.Hours,10&#41;&#41;-12&#41;;
			else
				finalHour=parseInt&#40;this.Hours,10&#41;-12;	
		&#125;
		else
		&#123;
			this.AMorPM="AM";
			if &#40;this.Hours<10&#41;
				finalHour="0"+parseInt&#40;this.Hours,10&#41;;
			else
				finalHour=this.Hours;	
		&#125;
	&#125;
	else if &#40;TimeMode==24&#41;
	&#123;
		if &#40;this.Hours<10&#41;
			finalHour="0"+parseInt&#40;this.Hours,10&#41;;
		else	
			finalHour=this.Hours;
	&#125;	
	return finalHour;	
&#125;				
Calendar.prototype.getShowHour=getShowHour;		

function GetMonthName&#40;IsLong&#41;
&#123;
	var Month=MonthName&#91;this.Month&#93;;
	if &#40;IsLong&#41;
		return Month;
	else
		return Month.substr&#40;0,3&#41;;
&#125;
Calendar.prototype.GetMonthName=GetMonthName;

function GetMonDays&#40;&#41;//Get number of days in a month
&#123;
	var DaysInMonth=&#91;31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31&#93;;
	if &#40;this.IsLeapYear&#40;&#41;&#41;
	&#123;
		DaysInMonth&#91;1&#93;=29;
	&#125;	
	return DaysInMonth&#91;this.Month&#93;;	
&#125;
Calendar.prototype.GetMonDays=GetMonDays;

function IsLeapYear&#40;&#41;
&#123;
	if &#40;&#40;this.Year%4&#41;==0&#41;
	&#123;
		if &#40;&#40;this.Year%100==0&#41; && &#40;this.Year%400&#41;!=0&#41;
		&#123;
			return false;
		&#125;
		else
		&#123;
			return true;
		&#125;
	&#125;
	else
	&#123;
		return false;
	&#125;
&#125;
Calendar.prototype.IsLeapYear=IsLeapYear;

function FormatDate&#40;pDate&#41;
&#123;
	if &#40;this.Format.toUpperCase&#40;&#41;=="DDMMYYYY"&#41;
		return &#40;pDate+DateSeparator+&#40;this.Month+1&#41;+DateSeparator+this.Year&#41;;
	else if &#40;this.Format.toUpperCase&#40;&#41;=="DDMMMYYYY"&#41;
		return &#40;pDate+DateSeparator+this.GetMonthName&#40;false&#41;+DateSeparator+this.Year&#41;;
	else if &#40;this.Format.toUpperCase&#40;&#41;=="MMDDYYYY"&#41;
		return &#40;&#40;this.Month+1&#41;+DateSeparator+pDate+DateSeparator+this.Year&#41;;
	else if &#40;this.Format.toUpperCase&#40;&#41;=="MMMDDYYYY"&#41;
		return &#40;this.GetMonthName&#40;false&#41;+DateSeparator+pDate+DateSeparator+this.Year&#41;;			
&#125;
Calendar.prototype.FormatDate=FormatDate;	
Δηλωση πεδιου :

Κώδικας: Επιλογή όλων

<label for="Birthdate">Birthdate&#58;</label> <input type="text" name="Birthdate" id="Birthdate" size="25"><a href="javascript&#58;NewCal&#40;'Birthdate','MMddyyyy'&#41;"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
Στη βαση ειναι ορισμενο ως :

Κώδικας: Επιλογή όλων

Birthdate  &#40; datetime &#41;

Άβαταρ μέλους
fafos
Script Master
Δημοσιεύσεις: 6230
Εγγραφή: 30 Νοέμ 2004 03:09

DateTime Picker

Δημοσίευση από fafos » 29 Νοέμ 2008 20:10

auta leitourgoun mia xara... steile mas kai ton php kodika pou kaneis insert thn hmeromhnia kathos kai ton kodika ths formas...

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 29 Νοέμ 2008 20:31

Κώδικας: Επιλογή όλων

$birth = mysql_real_escape_string&#40;$_POST&#91;'Birthdate'&#93;&#41;;
Ο τροπος που γραφω μπορει να σας μπερδεψει λιγο :

Κώδικας: Επιλογή όλων

******

 
Τελευταία επεξεργασία από το μέλος loxy την 29 Νοέμ 2008 21:14, έχει επεξεργασθεί 1 φορά συνολικά.

Άβαταρ μέλους
fafos
Script Master
Δημοσιεύσεις: 6230
Εγγραφή: 30 Νοέμ 2004 03:09

DateTime Picker

Δημοσίευση από fafos » 29 Νοέμ 2008 21:01

Prepei na xrhsimopoihseis thn DATE anti ths DATETIME kai oi hmeromhnies na einai morfhs:

ETOS-MHNAS-HMERA

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 29 Νοέμ 2008 21:15

Χμμμ!
θα το δοκιμασω...

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 29 Νοέμ 2008 22:43

Δυστυχως , δε γινεται.
Επιλεγω απο το ημερολογιο που εμφανιζεται ημερομηνια και εισαγει στο πεδιο της φορμας " undefined"...

Άβαταρ μέλους
fafos
Script Master
Δημοσιεύσεις: 6230
Εγγραφή: 30 Νοέμ 2004 03:09

DateTime Picker

Δημοσίευση από fafos » 30 Νοέμ 2008 14:26

Vres kapoion allon date picker... kapou edo exei steilei enan o Skeftomilos h mporeis na dokimaseis kai auton: http://www.dynarch.com/demos/jscalendar/

Άβαταρ μέλους
loxy
Δημοσιεύσεις: 208
Εγγραφή: 17 Ιούλ 2007 01:18

DateTime Picker

Δημοσίευση από loxy » 30 Νοέμ 2008 23:05

OK , βρεθηκε η λυση...

Απάντηση

Επιστροφή στο “JavaScript και Frameworks”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες