页面中点个按钮弹出个选择日期的日历小框,怎么弄弄?

257758 2003-06-10 02:59:18
页面中点个按钮弹出个选择日期的日历小框,怎么弄弄?
...全文
302 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
WarBaby 2003-09-28
  • 打赏
  • 举报
回复
我也来一个吧,自己写的,主要是使用方便,而且可以选择时间,另外自己感觉挺好看,最爽的是按住增加按钮试试吧!
示例在http://warbaby.myrice.com/timeopener.htm
加到自己页面的方法是,首先把http://warbaby.myrice.com/TimeChoose.htm保存到自己的目录下,然后在自己的HTML文件中的<input type=text ...>后面紧跟一个<input type=button id=choose value=选择 onclick="previousSibling.value=window.showModalDialog('TimeChoose.htm','','dialogWidth:10;dialogWidth:16;dialogHeight:11.5;status:0;help:0;dialogLeft:'+event.screenX+';dialogTop:'+event.screenY);scrollbars:0">就可以了

不明白就看源程序好了:)
linsr 2003-09-28
  • 打赏
  • 举报
回复
我有现成的原代码
已经运用于系统中
需要的话
请发email给我!
email:linsr3222
寒舍人 2003-09-28
  • 打赏
  • 举报
回复
up
cxjd 2003-09-26
  • 打赏
  • 举报
回复
up
chenfei00 2003-09-26
  • 打赏
  • 举报
回复
http://www.cntomorrow.com:3310/JSCalendar.htm

这是我用过最好用的...不看会后悔的..
spiritsl 2003-09-26
  • 打赏
  • 举报
回复
他们都说完了
看来我来晚了:(
smhilycwx 2003-07-17
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1696/1696476.xml?temp=.931164
很好的解决方法,:看一下 smhilycwx 恢复的帖子
Rayy 2003-07-17
  • 打赏
  • 举报
回复
http://www.softcomplex.com/products/tigra_calendar/


Dowload
mingjob 2003-07-17
  • 打赏
  • 举报
回复
meizz(梅花雪疏影横斜)网页日历 Web Calendar ver 3.0

http://expert.csdn.net/Expert/TopicView1.asp?id=1887844
LiGun 2003-06-18
  • 打赏
  • 举报
回复
gz
lovelanzhi716 2003-06-18
  • 打赏
  • 举报
回复
calendar.js文件内容如下:
var moy = new Array(
'一月','二月','三月',
'四月','五月','六月','七月',
'八月','九月','十月',
'十一月','十二月'
);

var daysOfMonth = new Array(
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
);

var daysOfMonthLY = new Array(
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
);

//var dow = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat',
// 'Sun','Mon','Tue','Wed','Thu','Fri');

var dow = new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六',
'Sun','Mon','Tue','Wed','Thu','Fri');

var size = 'width="50" height="25"';
var border = 'border="1"';

function isLeapYear(num) {
if (((num % 4 == 0) && (num % 100 != 0)) || (num % 400 == 0))
return true;
return false;
}

function CalendarSelect(Month,Year, offset) {//自动计算年月日并显示出来
if (offset == null) offset = 0;

if (window.changeMonth) { }
else {
alert('A changeMonth() function has not been defined');
return '';
}

if (window.changeYear) { }
else {
alert('A changeYear() function has not been defined');
return '';
}

if (window.changeDay) { }
else {
alert('A changeDay() function has not been defined');
return '';
}

var output = '';

output += '<form name="Cal">';
output += CalendarHead(Month,Year,true);
output += CalendarMonth(Month,Year,offset);
output += '</form>';

return output;
}//************************end************************

function CalendarHead(Month,Year,Select) {//输入表头中的月选择与年选择
var output = '';

output +=
'<table border="0" cellspacing="0" bordercolorlight="#9999cc" bordercolordark="#FFFFFF" cellpadding="0" class="cal">' +
'<tr><td align="left" width="100%" class="head"><font size="2">' +
moy[Month-1] + ' ' + Year +
'年</font></td>';

if (Select) {

output += '<td width="50%" align="right">' +
'<select name="Month" onChange="CalMonth()">';

for (var month=1; month<=12; month++) {
output += '<option value="' + month + '"';
if (month == Month) output += ' selected';
output += '>' + moy[month-1] + '</option>';
}

output += '</select>' +
'<select name="Year" onChange="CalYear();">';

for (var year=2000; year<=2020; year++) {
output += '<option value="' + year + '"';
if (year == Year) output += ' selected';
output += '>' + year + '</option>';
}

output += '</select>';
}

output += '</td></tr></table>';

return output;
}//***********************end*************************

function CalendarMonth(M,Y,offset) {//以表格形式显示月数据
M--;
if (offset == null) offset = 0;

firstDay = new Date(Y,M,1);
startDay = firstDay.getDay();

if (startDay < offset) startDay += 7;

var days = daysOfMonth;
if (isLeapYear(Y)) days = daysOfMonthLY;

var output = '';

output +=
'<table border="1" cellspacing="0" bordercolorlight="#9999cc" bordercolordark="#FFFFFF" cellpadding="0" align="center" class="cal"><tr>';

for (var i=0; i<7; i++)
output += '<td ' + size + ' class="days"><font size="2" color="999933">' +
dow[i + offset] + '</font></td>';

output += '</tr><tr>';

var column = 0;
var lastM = M - 1;
if (lastM == -1) lastM = 11;

for (var i=0+offset; i<startDay; i++, column++)
output += '<td ' + size + ' class="grey"><font size="2">' +
(days[lastM]-startDay+i+1) + '</font></td>';

for (var i=1; i<=days[M]; i++, column++) {
var style = ' class="links"';
if (day == i && month == M+1 && year == Y)
style = ' class="today"';
if (window.changeDay)
output += '<td ' + size + '><font size="2">' +
'<a href="javascript:CalDay('+Y+','+(M+1)+','+i+')"' +
style + '>' + i + '</a></font></td>';
else
output += '<td ' + size + style + '><font size="2">' + i + '</font></td>';

if (column == 6) {
output += '</tr><tr>';
column = -1;
}
}

if (column > 0) {
for (var i=1; column<7; i++, column++)
output += '<td ' + size + ' class="grey">' + i + '</td>';
}

output += '</tr></table>';

return output;
}//*********************end**********************

function getAnOptionValue(what) {
return what.options[what.options.selectedIndex].value;
}

function CalMonth() {
CalendarMonth = getAnOptionValue(document.Cal.Month) - 0;
changeMonth(CalendarMonth);
}

function CalYear() {
CalendarYear = getAnOptionValue(document.Cal.Year) - 0;
changeYear(CalendarYear);
}

function CalDay(year,month,day) {
CalendarDay = day;
CalendarMonth = month;
CalendarYear = year;
changeDay(CalendarYear,CalendarMonth,CalendarDay);
}

var CalendarMonth;
var CalendarYear;
var CalendarDay;


cal.html文件内容如下
<html>

<head>

<title>Calendar</title>

<!-- <link rel="stylesheet" href="calendar.css" type="text/css"> -->

<script language="JavaScript" src="calendar.js"></script>

<script language="JavaScript"><!--
function changeMonth() {
opener.month = CalendarMonth + '';
location.href = 'cal.htm';
}

function changeYear() {
opener.year = CalendarYear + '';
location.href = "cal.htm";
}

function changeDay(year,month,day) {
opener.day = CalendarDay + '';
opener.restart();
self.close();
}

var day = opener.day;
var month = opener.month;
var year = opener.year;
//--></script>

</head>

<body background="../image/sp.jpg" topmargin="2" leftmargin="5">

<center>

<script language="JavaScript"><!--
if (window.CalendarSelect)
document.write(CalendarSelect(opener.month,opener.year,0));
//--></script>

</center>

</body>

</html>


在你自己的HTML文件里面加上一个按钮就可以了,注意:这两个文件与你的HTML文件必须在同一个目录下面
<input type="text" name="date1" size="12" onclick="cal(document.form1.date1)">
lymkelly 2003-06-18
  • 打赏
  • 举报
回复
关注
shaopin 2003-06-10
  • 打赏
  • 举报
回复
金蝶、用友都用的日期控件:
http://expert.csdn.net/Expert/topic/1696/1696476.xml?temp=.9244654
biggie 2003-06-10
  • 打赏
  • 举报
回复
http://www.designac.org/js.htm
到我这下载
257758 2003-06-10
  • 打赏
  • 举报
回复
shizhuoheng@163.com
QQ:105385410
谢谢
dooby 2003-06-10
  • 打赏
  • 举报
回复


function fUpdateCal(iYear, iMonth) {

myMonth = fBuildCal(iYear, iMonth);

var i = 0;

for (w = 0; w < 6; w++)

for (d = 0; d < 7; d++)

with (cellText[(7*w)+d]) {

Victor = i++;

if (myMonth[w+1][d]<0) {

color = gcGray;

innerText = -myMonth[w+1][d];

}else{

color = ((d==0)||(d==6))?"red":"black";

innerText = myMonth[w+1][d];

}

}

}



function fSetYearMon(iYear, iMon){

tbSelMonth.options[iMon-1].selected = true;

for (i = 0; i < tbSelYear.length; i++)

if (tbSelYear.options[i].value == iYear)

tbSelYear.options[i].selected = true;

fUpdateCal(iYear, iMon);

}



function fPrevMonth(){

var iMon = tbSelMonth.value;

var iYear = tbSelYear.value;



if (--iMon<1) {

iMon = 12;

iYear--;

}



fSetYearMon(iYear, iMon);

}



function fNextMonth(){

var iMon = tbSelMonth.value;

var iYear = tbSelYear.value;



if (++iMon>12) {

iMon = 1;

iYear++;

}



fSetYearMon(iYear, iMon);

}



function fToggleTags(){

with (document.all.tags("SELECT")){

for (i=0; i<length; i++)

if ((item(i).Victor!="Won")&&fTagInBound(item(i))){

item(i).style.visibility = "hidden";

goSelectTag[goSelectTag.length] = item(i);

}

}

}



function fTagInBound(aTag){

with (VicPopCal.style){

var l = parseInt(left);

var t = parseInt(top);

var r = l+parseInt(width);

var b = t+parseInt(height);

var ptLT = fGetXY(aTag);

return !((ptLT.x>r)||(ptLT.x+aTag.offsetWidth<l)||(ptLT.y>b)||(ptLT.y+aTag.offsetHeight<t));

}

}



function fGetXY(aTag){

var oTmp = aTag;

var pt = new Point(0,0);

do {

pt.x += oTmp.offsetLeft;

pt.y += oTmp.offsetTop;

oTmp = oTmp.offsetParent;

} while(oTmp.tagName!="BODY");

return pt;

}



var gMonths = new Array(" 一月"," 二月"," 三月"," 四月"," 五月"," 六月"," 七月"," 八月"," 九月"," 十月","十一月","十二月");



with (document) {

write("<Div id='VicPopCal' onclick='event.cancelBubble=true' style='POSITION:absolute;visibility:hidden;border:2px ridge;width:10;z-index:100;'>");

write("<table border='0' bgcolor='#6699cc'>");

write("<TR>");

write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:20;width:20;FONT:bold' onClick='fPrevMonth()'>");

write(" <SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>");

for(i=1990;i<2015;i++)

write("<OPTION value='"+i+"'>"+i+"年</OPTION>");

write("</SELECT>");

write(" <select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>");

for (i=0; i<12; i++)

write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");

write("</SELECT>");

write(" <input type='button' name='PrevMonth' value='>' style='height:20;width:20;FONT:bold' onclick='fNextMonth()'>");

write("</td>");

write("</TR><TR>");

write("<td align='center'>");

write("<DIV style='background-color:#999999'><table width='100%' border='0' cellpadding='2'>");

fDrawCal(giYear, giMonth, 12, 12);

write("</table></DIV>");

write("</td>");

write("</TR><TR><TD align='center'>");

write("<B style='cursor:hand; font: bold 14 宋体' onclick='fSetDate(giYear,giMonth,giDay)' onMouseOver='this.style.color=gcToggle' onMouseOut='this.style.color=0'>今天:"+giYear+"年"+giMonth+"月"+giDay+"日</B>");

write("</TD></TR>");

write("</TABLE></Div>");

write("<SCRIPT event=onclick() for=document>fHideCalendar()</SCRIPT>");

}



// End -- Coded by Liming Weng, email: victorwon@netease.com -->


在前台调用方式如下
首先要引入 <script Language= "JavaScript" src="PopCalendar.js"></script>
在需要的位置写入
<td align="left" height="35" colspan="2">
<input name="zbsj1" type="text" class="Menu100" READONLY maxlength="10" value ="<%=frontDate%>">
<img src="time.gif" width="17" height="16" align="absmiddle" alt="弹出日历下拉菜单" onClick="fPopCalendar(zbsj1,zbsj1);return false;" style="cursor:hand;">至</td>
<td align="left" height="35">
<input name="zbsj2" type="text" class="Menu100" READONLY size="12" maxlength="10" value ="<%=currDate%>">
<img src="time.gif" width="17" height="16" align="absmiddle" alt="弹出日历下拉菜单" onClick="fPopCalendar(zbsj2,zbsj2);return false;" style="cursor:hand;">
</td>
dooby 2003-06-10
  • 打赏
  • 举报
回复
编写一个js文件 代码如下

<!-- Begin //place these scripts within BODY tag if you are using IE 4.0 or below.

//****************************************************************************

// PopCalendar 3.50, Emailware(please mail&commend me if u like it)

// Originally coded by Liming(Victor) Weng, email: victorwon@netease.com

// Release date: 2000.3.13

// Anyone may modify it to satify his needs, but please leave this comment ahead.

//****************************************************************************



var gdCtrl = new Object();

var gdCtrl2 = new Object();

var goSelectTag = new Array();

var gcGray = "#808080";

var gcToggle = "#ffff00";

var gcBG = "#cccccc";



var gdCurDate = new Date();

var giYear = gdCurDate.getFullYear();

var giMonth = gdCurDate.getMonth()+1;

var giDay = gdCurDate.getDate();



function arrowtag(namestr,valuestr)

{

document.write("<input type='text' name='"+namestr+"' value='"+valuestr+"' size='10' style='text-align: center;' onclick='fPopCalendar("+namestr+","+namestr+");return false' onfocus='fPopCalendar("+namestr+","+namestr+");return false'>");

}



//****************************************************************************

// Param: popCtrl is the widget beyond which you want this calendar to appear;

// dateCtrl is the widget into which you want to put the selected date.

// i.e.: <input type="text" name="dc" style="text-align:center" readonly><INPUT type="button" value="V" onclick="fPopCalendar(dc,dc);return false">

//****************************************************************************

function fPopCalendar(popCtrl, dateCtrl){

event.cancelBubble=true;

gdCtrl = dateCtrl;

fSetYearMon(giYear, giMonth);

var point = fGetXY(popCtrl);

with (VicPopCal.style) {

left = point.x;

top = point.y+popCtrl.offsetHeight+1;

width = VicPopCal.offsetWidth;

height = VicPopCal.offsetHeight;

fToggleTags(point);

visibility = 'visible';

}

VicPopCal.focus();

}

/**
* this Mothed is added by FengJie(FengJie@neusoft.com) for put date into 2 widgets together
*/
function fPopCalendar2(popCtrl, dateCtrl, dateCtrl2){

event.cancelBubble=true;

gdCtrl = dateCtrl;

gdCtrl2 = dateCtrl2;

fSetYearMon(giYear, giMonth);

var point = fGetXY(popCtrl);

with (VicPopCal.style) {

left = point.x;

top = point.y+popCtrl.offsetHeight+1;

width = VicPopCal.offsetWidth;

height = VicPopCal.offsetHeight;

fToggleTags(point);

visibility = 'visible';

}

VicPopCal.focus();

}


function fSetDate(iYear, iMonth, iDay){

if (iDay<10) iDay='0'+iDay;
if (iMonth<10) iMonth='0'+iMonth;//added by zhaoshijie 2002-09-25;
gdCtrl.value = iYear+"-"+iMonth+"-"+iDay; //Here, you could modify the locale as you need !!!!
gdCtrl2.value = gdCtrl.value;


fHideCalendar();

}



function fHideCalendar(){

VicPopCal.style.visibility = "hidden";

for (i in goSelectTag)

goSelectTag[i].style.visibility = "visible";

goSelectTag.length = 0;

}



function fSetSelected(aCell){

var iOffset = 0;

var iYear = parseInt(tbSelYear.value);

var iMonth = parseInt(tbSelMonth.value);



aCell.bgColor = gcBG;

with (aCell.children["cellText"]){

var iDay = parseInt(innerText);

if (color==gcGray)

iOffset = (Victor<10)?-1:1;

iMonth += iOffset;

if (iMonth<1) {

iYear--;

iMonth = 12;

}else if (iMonth>12){

iYear++;

iMonth = 1;

}

}

fSetDate(iYear, iMonth, iDay);

}



function Point(iX, iY){

this.x = iX;

this.y = iY;

}



function fBuildCal(iYear, iMonth) {

var aMonth=new Array();

for(i=1;i<7;i++)

aMonth[i]=new Array(i);



var dCalDate=new Date(iYear, iMonth-1, 1);

var iDayOfFirst=dCalDate.getDay();

var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();

var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;

var iDate = 1;

var iNext = 1;



for (d = 0; d < 7; d++)

aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;

for (w = 2; w < 7; w++)

for (d = 0; d < 7; d++)

aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);

return aMonth;

}



function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {

var WeekDay = new Array("日","一","二","三","四","五","六");

var styleTD = " bgcolor='"+gcBG+"' bordercolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font:bold "+iDateTextSize+" 宋体;"; //Coded by Liming Weng(Victor Won) email:victorwon@netease.com



with (document) {

write("<tr>");

for(i=0; i<7; i++)

write("<td "+styleTD+"color:#990099' >" + WeekDay[i] + "</td>");

write("</tr>");



for (w = 1; w < 7; w++) {

write("<tr>");

for (d = 0; d < 7; d++) {

write("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");

write("<font id=cellText Victor='Liming Weng'> </font>");

write("</td>")

}

write("</tr>");

}

}

}

yangjuanli 2003-06-10
  • 打赏
  • 举报
回复
用javascript可以用实现呀。
留下你的E-mail我可以给你发过去。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧