當前位置:首頁 » 課程設計 » js日歷控制項課程表

js日歷控制項課程表

發布時間: 2021-03-02 22:38:14

1. 在jsp頁面中調用js的日歷控制項,如何操作

在jsp頁面中使用js日期控制項
<script src="js/Calendar.js" type="text/javascript" language="javascript"></script>
加入到頁面中 js/Calendar.js 這是內控制項的容路徑
<input name="txtDate" type="text" onclick="SelectDate(this)" readonly="readonly">

2. 日歷控制項calendar.js怎麼調用

以3.0為例:
項目head塊中寫入以下:
<script language="javascript" type="text/javascript" src="~/canlendar.js"></script>
調用時在所要用日期的TextBox控制項加入onclick事件:onclick='popUpCalendar(this,document.form1.TextBox1,"yyyy-mm-dd")'

以上方法名回popUpCalendar不同版本可能會不同,調用時看答源碼

3. 我想用js實現日歷加時間的下拉框,類似12306網站出行日期那樣的框框再加上時間,謝謝!

自己抄寫要花很多的時間、襲而且還不一定那麼好用、網上有好些別人寫好的、可以拿來用、
http://www.my97.net/

4. 求一個JS日期控制項。精確到月就行了

用的時候先在<head></head>插入

<SCRIPT src="Images/setday.js"></SCRIPT>
然後輸入框

<INPUT id="starttime2" onclick="setday(this)" size="12" name="starttime" runat="server">

setday.js代碼如下:

<SCRIPT>
document.writeln('<div id=meizzDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
document.writeln('<span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#000000 onselectstart="return false">');
document.writeln(' <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
document.writeln(' <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' onclick="meizzPrevM()" title="前一月" Author=meizz><b Author=meizz><</b>');
document.writeln(' </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');

document.writeln(' <span Author=meizz id=meizzYearHead onmouseover="style.backgroundColor='yellow'" onmouseout="style.backgroundColor='white'" title="點擊這里選擇年份" onclick="tmpSelectYearInnerHTML(this.innerText)" style="cursor: hand;"></span>年<span');
document.writeln(' id=meizzMonthHead Author=meizz onmouseover="style.backgroundColor='yellow'" onmouseout="style.backgroundColor='white'" title="點擊這里選擇月份" onclick="tmpSelectMonthInnerHTML(this.innerText)" style="cursor: hand;"></span>月</td>');

document.writeln(' <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' onclick="meizzNextM()" title="後一月" Author=meizz><b Author=meizz>></b></td></tr>');
document.writeln(' </table></td></tr>');
document.writeln(' <tr><td width=142 height=18 bgcolor=#808080>');
document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz class="td1">一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>');
document.writeln('</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: [email protected] 2002-10-8 -->');
document.writeln(' <tr><td width=142 height=120>');
document.writeln(' <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF>');
var n=0; for (j=0;j<5;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
document.writeln('<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=meizzDayClick(this.innerText)></td>');n++;}
document.writeln('</tr>');}
document.writeln(' <tr align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
document.writeln(' onclick=meizzDayClick(this.innerText)></td>');
document.writeln(' <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz onclick=meizzDayClick(this.innerText)></td>');
document.writeln(' <td colspan=5 align=right Author=meizz><span onclick=closeLayer() style="font-size:12px;cursor: hand"');
document.writeln(' Author=meizz title="返回(不選擇日期)"><u>關閉</u></span></td></tr>');
document.writeln(' </table></td></tr><tr><td>');
document.writeln(' <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
document.writeln(' <tr><td Author=meizz align=left><input Author=meizz type=button value="<<" title="前一年" onclick="meizzPrevY()" ');
document.writeln(' onfocus="this.blur()" style=" cursor: hand;BACKGROUND-COLOR: #808080;BORDER-BOTTOM: #808080 1px outset; BORDER-LEFT: #808080 1px outset; BORDER-RIGHT: #808080 1px outset; BORDER-TOP: #808080 1px outset; FONT-SIZE: 12px; height: 20px;color: #FFD700; font-weight: bold"><input Author=meizz title="前一月" type=button ');
document.writeln(' value="<" onclick="meizzPrevM()" onfocus="this.blur()" style="cursor: hand;BACKGROUND-COLOR: #808080;BORDER-BOTTOM: #808080 1px outset; BORDER-LEFT: #808080 1px outset; BORDER-RIGHT: #808080 1px outset; BORDER-TOP: #808080 1px outset;font-size: 12px; height: 20px;color: #FFD700; font-weight: bold"></td><td ');
document.writeln(' Author=meizz align=center><input Author=meizz type=button value="重置" onclick="meizzToday()" ');
document.writeln(' onfocus="this.blur()" title="顯示當前時間" style="cursor: hand;BACKGROUND-COLOR: #808080;BORDER-BOTTOM: #808080 1px outset; BORDER-LEFT: #808080 1px outset; BORDER-RIGHT: #808080 1px outset; BORDER-TOP: #808080 1px outset;font-size: 12px; height: 20px;color: #FFFFFF; font-weight: bold"></td><td ');
document.writeln(' Author=meizz align=right><input Author=meizz type=button value=">" onclick="meizzNextM()" ');
document.writeln(' onfocus="this.blur()" title="後一月" style="cursor: hand;BACKGROUND-COLOR: #808080;BORDER-BOTTOM: #808080 1px outset; BORDER-LEFT: #808080 1px outset; BORDER-RIGHT: #808080 1px outset; BORDER-TOP: #808080 1px outset;font-size: 12px; height: 20px;color: #FFD700; font-weight: bold"><input ');
document.writeln(' Author=meizz type=button value=" >>" title="後一年" onclick="meizzNextY()"');
document.writeln(' onfocus="this.blur()" style="cursor: hand;BACKGROUND-COLOR: #808080;BORDER-BOTTOM: #808080 1px outset; BORDER-LEFT: #808080 1px outset; BORDER-RIGHT: #808080 1px outset; BORDER-TOP: #808080 1px outset;font-size: 12px; height: 20px;color: #FFD700; font-weight: bold"></td>');
document.writeln('</tr></table></td></tr></table></div>');

var outObject;
function setday(tt,obj) //主調函數
{
if (arguments.length > 2){alert("對不起!傳入本控制項的參數太多!");return;}
if (arguments.length == 0){alert("對不起!您沒有傳回本控制項任何參數!");return;}
var dads = document.all.meizzDateLayer.style;var th = tt;
var ttop = tt.offsetTop; //TT控制項的定位點高
var thei = tt.clientHeight; //TT控制項本身的高
var tleft = tt.offsetLeft; //TT控制項的定位點寬
var ttyp = tt.type; //TT控制項的類型
while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6;
dads.left = tleft;
outObject = (arguments.length == 1) ? th : obj;
dads.display = '';
event.returnValue=false;
}

var MonHead = new Array(12); //定義陽歷中每個月的最大天數
MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;

var meizzTheYear=new Date().getFullYear(); //定義年的變數的初始值
var meizzTheMonth=new Date().getMonth()+1; //定義月的變數的初始值
var meizzWDay=new Array(37); //定義寫日期的數組

function document.onclick() //任意點擊時關閉該控制項
{
with(window.event.srcElement)
{ if (tagName != "INPUT" && getAttribute("Author")==null)
document.all.meizzDateLayer.style.display="none";
}
}

function meizzWriteHead(yy,mm) //往 head 中寫入當前的年與月
{ document.all.meizzYearHead.innerText = yy;
document.all.meizzMonthHead.innerText = mm;
}

function tmpSelectYearInnerHTML(strYear) //年份的下拉框
{
if (strYear.match(/D/)!=null){alert("年份輸入參數不是數字!");return;}
var m = (strYear) ? strYear : new Date().getFullYear();
if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之間!");return;}
var n = m - 10;
if (n < 1000) n = 1000;
if (n + 26 > 9999) n = 9974;
var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
s += "onblur='document.all.tmpSelectYearLayer.style.display="none"' "
s += "onchange='document.all.tmpSelectYearLayer.style.display="none";"
s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'> ";
var selectInnerHTML = s;
for (var i = n; i < n + 26; i++)
{
if (i == m)
{selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option> ";}
else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option> ";}
}
selectInnerHTML += "</select>";
document.all.tmpSelectYearLayer.style.display="";
document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
document.all.tmpSelectYear.focus();
}

function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
{
if (strMonth.match(/D/)!=null){alert("月份輸入參數不是數字!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
s += "onblur='document.all.tmpSelectMonthLayer.style.display="none"' "
s += "onchange='document.all.tmpSelectMonthLayer.style.display="none";"
s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'> ";
var selectInnerHTML = s;
for (var i = 1; i < 13; i++)
{
if (i == m)
{selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option> ";}
else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option> ";}
}
selectInnerHTML += "</select>";
document.all.tmpSelectMonthLayer.style.display="";
document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
document.all.tmpSelectMonth.focus();
}

function closeLayer() //這個層的關閉
{
document.all.meizzDateLayer.style.display="none";
}

function document.onkeydown()
{
if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none";
}

function IsPinYear(year) //判斷是否閏平年
{
if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
}

function GetMonthCount(year,month) //閏年二月為29天
{
var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
}

function GetDOW(day,month,year) //求某天的星期幾
{
var dt=new Date(year,month-1,day).getDay()/7; return dt;
}

function meizzPrevY() //往前翻 Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
else{alert("年份超出范圍(1000-9999)!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextY() //往後翻 Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
else{alert("年份超出范圍(1000-9999)!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzToday() //Today Button
{
meizzTheYear = new Date().getFullYear();
meizzTheMonth = new Date().getMonth()+1;
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzPrevM() //往前翻月份
{
if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextM() //往後翻月份
{
if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
meizzSetDay(meizzTheYear,meizzTheMonth);
}

function meizzSetDay(yy,mm) //主要的寫程序**********
{
meizzWriteHead(yy,mm);
for (var i = 0; i < 37; i++){meizzWDay[i]=""}; //將顯示框的內容全部清空
var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期幾
for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
for (var i = 0; i < 37; i++)
{ var da = eval("document.all.meizzDay"+i) //書寫新的一個月的日期星期排列
if (meizzWDay[i]!="")
{ da.innerHTML = "<b>" + meizzWDay[i] + "</b>";
da.style.backgroundColor = (yy == new Date().getFullYear() &&
mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#73a6de";
da.style.cursor="hand"
}
else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
}
}
function meizzDayClick(n) //點擊顯示框選取日期,主輸入函數*************
{
var yy = meizzTheYear;
var mm = meizzTheMonth;
if (mm < 10){mm = "0" + mm;}
if (outObject)
{
if (!n) {outObject.value=""; return;}
if ( n < 10){n = "0" + n;}
outObject.value= yy + "-" + mm + "-" + n ; //註:在這里你可以輸出改成你想要的格式
closeLayer();
}
else {closeLayer(); alert("您所要輸出的控制項對象並不存在!");}
}
meizzSetDay(meizzTheYear,meizzTheMonth);
</script>

5. 求js日歷控制項(登錄jsp頁面就直接顯示出日歷的效果,然後點擊可以實現待辦事物的功能)如下所示

加QQ,發給你

6. 誰有JS日歷控制項 美觀的

我一直都用這個日期控制項

http://www.my97.net/

1.強大的日期范圍限制功能
支持靜態限制,動態限制,腳本自定義限制,以及無效天和無效日期功能,利用這樣功能你可以任意定製不能選擇的日期,這些日期即使毫無規律,毫無連續性,你也可以通過這些功能的組合使用輕松搞定.

2.自定義事件和豐富的API庫
如果你需要做一些附加的操作,你也不必擔心,日期控制項自帶的自定義事件可以滿足你的需求.此外,你還可以在自定義事件中調用提供的API庫來做更多的運算和擴展,絕對可以通過很少的代碼滿足你及其個性化的需求.

3.多語言支持和自定義皮膚支持
通過lang屬性,可以為每個日期控制項單獨配置語言,當然也可以通過WdatePicker.js配置全局的語言,皮膚也是一樣,只要配置skin屬性即可.這樣一個頁面中可以顯示多種語言,多種皮膚的日期控制項,更棒的是,他們之間的切換是無刷新的.

4.跨無限級框架顯示和自動選擇顯示位置
無論你把日期控制項放在哪裡,你都不需要擔心會被外層的iframe所遮擋進而影響客戶體驗,My97日期控制項是可以跨無限級框架顯示的,並且當控制項處在頁面邊界是,它會自動選擇顯示的位置.此外你還可以使用position參數對彈出位置做調整.

7. js動態的添加日期控制項

日歷控制項的演算法代碼很多很復雜的。
你可以去下一個日歷插件、網上有很多的。

8. Javascript怎麼實現這樣的日期控制項

這里有一個js日歷控制項
你可以參考一下

9. 在js中,怎麼用使用日歷控制項而且日歷控制項怎麼來的

找一個現成的js日期控制項了
我有一個,你可以根據自己需要改樣式,我改的時候有些注釋

10. 有什麼比較好用的js日期控制項

用Jquery 就不用頭疼了 UI里就有 調用也很簡單
<link href="css/back/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.custom.min.js"></script>
時間:<input type="text" class="dp_date" name="publishTime" id="datepicker"/></td>
<script type="text/javascript">
$(document).ready(function(){
$(function() {
$("#datepicker").datepicker({
dateFormat:'yy-mm-dd',
changeMonth : true,
changeYear : true
});
});
});
</script>

熱點內容
幼師專業怎麼樣 發布:2021-03-16 21:42:13 瀏覽:24
音樂小毛驢故事 發布:2021-03-16 21:40:57 瀏覽:196
昂立中學生教育閘北 發布:2021-03-16 21:40:47 瀏覽:568
建築業一建報考條件 發布:2021-03-16 21:39:53 瀏覽:666
2017年教師資格注冊結果 發布:2021-03-16 21:39:49 瀏覽:642
中國教師資格證查分 發布:2021-03-16 21:39:41 瀏覽:133
踵什麼成語有哪些 發布:2021-03-16 21:38:20 瀏覽:962
東營幼師專業學校 發布:2021-03-16 21:35:26 瀏覽:467
機械電子研究生課程 發布:2021-03-16 21:33:36 瀏覽:875
杭州朝日教育培訓中心怎麼樣 發布:2021-03-16 21:33:28 瀏覽:238