全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2108
推到 Plurk!
推到 Facebook!

Intraweb datepicker範例

缺席
";
else
htmloDayTable ="";
for(j=0;j<7;j )
{

if(i==0)
{
htmloDayTable =""
}
}
htmloDayTable ="";
}
htmloDayTable ="
frappe
中階會員


發表:88
回覆:114
積分:95
註冊:2008-10-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-01-06 01:26:26 IP:220.133.xxx.xxx 訂閱
 我在網路上看到一篇範例, 感覺滿實用的,但是照步驟做, 按button都沒反應
網址


[code delphi]


在窗体上拉一个 iwedit1与iwbutton1,iwbutton2一看这一个大家都明白我想要做什么了吧?是的,用iwbutton1仿tms日期选择控件的小按钮.
代码如下
form的javascript 属性里面加入如下的js

function PopupCalendar(InstanceName)
{
///Global Tag
this.instanceName=InstanceName;
///Properties
this.separator="-"
this.oBtnTodayTitle="Today"
this.oBtnCancelTitle="Cancel"
this.weekDaySting=new Array("S","M","T","W","T","F","S");
this.monthSting=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
this.Width=200;
this.currDate=new Date();
this.today=new Date();
this.startYear=1970;
this.endYear=2099;
///Css
this.normalfontColor="#666666";
this.selectedfontColor="red";
this.divBorderCss="1px solid #BCD0DE";
this.titleTableBgColor="#98B8CD";
this.tableBorderColor="#CCCCCC"
///Method
this.Init=CalendarInit;
this.Fill=CalendarFill;
this.Refresh=CalendarRefresh;
this.Restore=CalendarRestore;
///HTMLObject
this.oTaget=null;
this.oPreviousCell=null;
this.sDIVID=InstanceName "_Div";
this.sTABLEID=InstanceName "_Table";
this.sMONTHID=InstanceName "_Month";
this.sYEARID=InstanceName "_Year";
this.sTODAYBTNID=InstanceName "_TODAYBTN";

}
function CalendarInit() ///Create panel
{
var sMonth,sYear
sMonth=this.currDate.getMonth();
sYear=this.currDate.getYear();
htmlAll="
";
for(i=0;i<12;i )
{
htmloMonth ="";
}
htmloMonth ="</select>";
/// Year
htmloYear="<select id='" this.sYEARID "' this.instanceName ") ='font-size:13px'>";
for(i=0;i<=6;i )
{
if(i==0)
htmloDayTable ="
htmloDayTable =" CalendarCellsMsOver(" this.instanceName ")";
htmloDayTable =" CalendarCellsMsOut(" this.instanceName ")";
htmloDayTable =" CalendarCellsClick(this," this.instanceName ")>";
htmloDayTable ="
";
/// Today Button
htmloButton="
htmloButton =" CalendarTodayClick(" this.instanceName ")>" this.oBtnTodayTitle "</button> "
htmloButton ="<button .color=this.normalfontColor; <br /> }
CalendarCellSetCss(0,currRow.cells[cellIndex]);
iDaySn ;
if(iDaySn>MaxDay)break;
}
}
}
function CalendarRestore() /// Clear Data
{
var i,j,oTable
oTable=document.all[this.sTABLEID]
for(i=1;i {
for(j=0;j {
CalendarCellSetCss(0,oTable.rows[i].cells[j]);
oTable.rows[i].cells[j]=" ";
}
}
}
function CalendarRefresh(newDate) ///
{
this.currDate=newDate;
this.Restore();
this.Fill();
}
function CalendarCellsMsOver(oInstance) /// Cell MouseOver
{
var myCell = event.srcElement;
CalendarCellSetCss(0,oInstance.oPreviousCell);
if(myCell)
{
CalendarCellSetCss(1,myCell);
oInstance.oPreviousCell=myCell;
}
}
function CalendarCellsMsOut(oInstance) ////// Cell MouseOut
{
var myCell = event.srcElement;
CalendarCellSetCss(0,myCell);
}
function CalendarYearChange(oInstance) /// Year Change
{
var sDay,sMonth,sYear,newDate
sDay=oInstance.currDate.getDate();
sMonth=oInstance.currDate.getMonth();
sYear=document.all[oInstance.sYEARID].value
newDate=new Date(sYear,sMonth,sDay);
oInstance.Refresh(newDate);
}
function CalendarMonthChange(oInstance) /// Month Change
{
var sDay,sMonth,sYear,newDate
sDay=oInstance.currDate.getDate();
sMonth=document.all[oInstance.sMONTHID].value
sYear=oInstance.currDate.getYear();
newDate=new Date(sYear,sMonth,sDay);
oInstance.Refresh(newDate);
}
function CalendarCellsClick(oCell,oInstance)
{
var sDay,sMonth,sYear,newDate
sYear=oInstance.currDate.getFullYear();
sMonth=oInstance.currDate.getMonth();
sDay=oInstance.currDate.getDate();
if(oCell.innerText!=" ")
{
sDay=parseInt(oCell.innerText);
if(sDay!=oInstance.currDate.getDate())
{
newDate=new Date(sYear,sMonth,sDay);
oInstance.Refresh(newDate);
}
}
sDateString=sYear oInstance.separator CalendarDblNum(sMonth 1) oInstance.separator CalendarDblNum(sDay); ///return sDateString
if(oInstance.oTaget.tagName.toLowerCase()=="input")oInstance.oTaget.value = sDateString;
CalendarCancel(oInstance);
return sDateString;
}
function CalendarTodayClick(oInstance) /// "Today" button Change
{
oInstance.Refresh(new Date());
}
function getDateString(oInputSrc,oInstance)
{
if(oInputSrc&&oInstance)
{
var CalendarDiv=document.all[oInstance.sDIVID];
oInstance.oTaget=oInputSrc;
CalendarDiv.style.pixelLeft=CalendargetPos(oInputSrc,"Left");
CalendarDiv.style.pixelTop=CalendargetPos(oInputSrc,"Top") oInputSrc.offsetHeight;
CalendarDiv.style.display=(CalendarDiv.style.display=="none")?"":"none";
}
}
function CalendarCellSetCss(sMode,oCell) /// Set Cell Css
{
// sMode
// 0: OnMouserOut 1: "1px solid #5589AA";
oCell.style.backgroundColor="#BCD0DE";
}
else
{
oCell.style.border="1px solid #FFFFFF";
oCell.style.backgroundColor="#FFFFFF";
}
}
function CalendarGetMaxDay(nowYear,nowMonth) /// Get MaxDay of current month
{
var nextMonth,nextYear,currDate,nextDate,theMaxDay
nextMonth=nowMonth 1;
if(nextMonth>11)
{
nextYear=nowYear 1;
nextMonth=0;
}
else
{
nextYear=nowYear;
}
currDate=new Date(nowYear,nowMonth,1);
nextDate=new Date(nextYear,nextMonth,1);
theMaxDay=(nextDate-currDate)/(24*60*60*1000);
return theMaxDay;
}
function CalendargetPos(el,ePro) /// Get Absolute Position
{
var ePos=0;
while(el!=null)
{
ePos =el["offset" ePro];
el=el.offsetParent;
}
return ePos;
}
function CalendarDblNum(num)
{
if(num < 10)
return "0" num;
else
return num;
}
function CalendarCancel(oInstance) ///Cancel
{
var CalendarDiv=document.all[oInstance.sDIVID];
CalendarDiv.style.display="none";
}
var oCalendarEn=new PopupCalendar("oCalendarEn"); //初始化控件时,请给出实例名称如:oCalendarEn
oCalendarEn.Init();

var oCalendarChs=new PopupCalendar("oCalendarChs"); //初始化控件时,请给出实例名称:oCalendarChs
oCalendarChs.weekDaySting=new Array("日","一","二","三","四","五","六");
oCalendarChs.monthSting=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
oCalendarChs.oBtnTodayTitle="今天";
oCalendarChs.oBtnCancelTitle="取消";
oCalendarChs.Init();

然后呢,在iwbutton1的scriptevents."test";

var xx=document.getElementById(s);
getDateString(xx,oCalendarEn);

在iwbutton2的scriptevents."test";

var xx=document.getElementById(s);
getDateString(xx,oCalendarChs);


好了到此完成,分别按一下iwbutton1与iwbutton2就可以看到效果了,


[/code]
系統時間:2017-12-12 2:53:42
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!