淘寶網日曆控件js代碼,web日曆控件

本文目錄一覽:

點在圖片上 顯示日曆框 可以選擇日曆上的日期 來查詢對應時間數據庫的信息 這個JSP代碼怎麼寫

%@ page contentType=”text/html; charset=gb2312″ %

%@ page language=”java” import=”java.util.*” %

%

response.setHeader(“Cache-Control”, “no-store”);

response.setHeader(“Pragma”, “no-cache”);

response.setDateHeader(“Expires”, 0);

%

html

head

title選擇日期/title

meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″

META name=”GENERATOR” content=”IBM WebSphere Studio”

style

SELECT {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}

TEXTAREA {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}

INPUT {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}

TD {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}

.p { font-size: 12px; line-height: 18px}

.pp { font-size: 14px; line-height: 18px}

.cals{font-family: “Arial”color:#000000; font-size:10pt}

/style

%@page import = “java.util.StringTokenizer”%

%

String type = request.getParameter(“type”);

if (type==null) type=”1″;

Calendar cal = Calendar.getInstance();

String cur_date = cal.get(Calendar.YEAR) + “年” + (cal.get(Calendar.MONTH)+1)

+ “月” + cal.get(Calendar.DAY_OF_MONTH)+”日”;

int cur_year = cal.get(Calendar.YEAR);

int cur_month = (cal.get(Calendar.MONTH)+1);

int cur_day = cal.get(Calendar.DAY_OF_MONTH);

String cur_date_string = String.valueOf(cur_year) + “-“

+ (cur_month10?(“0″+String.valueOf(cur_month)):String.valueOf(cur_month)) + “-“

+ (cur_day10?(“0″+String.valueOf(cur_day)):String.valueOf(cur_day));

String parmInitDate = request.getParameter(“initdate”);

int parm_year=0;

int parm_month=0;

int parm_day=0;

if(parmInitDate!=null){

StringTokenizer mytoken = null;

try{

java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(“yyyy-MM-dd”);

java.util.Date date = null;

date = formatter.parse(parmInitDate);

//java.util.Calendar cal = new java.util.Calendar()

cal.setTime(date);

parm_year = cal.get(Calendar.YEAR);

parm_month = cal.get(Calendar.MONTH) + 1;

parm_day = cal.get(Calendar.DAY_OF_MONTH );

}catch(Exception e){

//out.print(e);

}

}

parm_year= parm_year==0?cur_year:parm_year;

parm_month= parm_month==0?cur_month:parm_month;

parm_day= parm_day==0?cur_day:parm_day;

%

script LANGUAGE=”vbscript”

!–

dim cal(6,7)

dim sToday

dim sCurDate

dim sSeldate

dim selx,sely

sCurdate=”%=cur_date_string%”

sSeldate=”%=parm_year+”-“+parm_month+”-“+parm_day%”

sub getDate()

if window.event.srcElement.innerText = “” or window.event.srcElement.innerText = ” ” then exit sub

for i = 1 to 6

for j = 1 to 7

if cal(i,j).bgcolor=”#0000ff” then

cal(i,j).bgcolor=””

cal(i,j).style.color=”black”

end if

next

next

if window.event.srcElement.bgcolor”#ffff00″ then

window.event.srcElement.bgcolor=”blue”

window.event.srcElement.style.color=”white”

end if

aa = window.year.value “-” right(window.month.value+100,2) “-” right(window.event.srcelement.innertext+100,2)

window.sel_date.innerText=aa

end sub

sub getTime()

aa=””

if window.hour.value”00″ or window.minute.value”00″ or window.second.value”00″ then

aa=window.hour.value “:” window.minute.value “:” window.second.value

end if

if window.sel_date.innerText = “” then

window.sel_date.innerText = sCurDate

end if

window.sel_time.innerText=aa

end sub

sub ret ()

if window.sel_date.innerText “” then

window.returnValue = window.sel_date.innerText

if window.sel_time.innerText=”” then

window.sel_time.innerText=window.hour.value “:” window.minute.value “:” window.second.value

end if

if window.sel_time.innerText “” then

window.returnValue = window.sel_date.innerText ” ” window.sel_time.innerText

end if

end if

window.event.returnValue = false

set cal(6,7) = nothing

window.close()

end sub

sub cancel ()

window.returnValue = “”

window.event.returnValue = false

set cal(6,7) = nothing

window.close()

end sub

sub draw

dim yy,mm,dd,thisday,lastmm,maxday

dim nextmm

yy = window.year.value

mm = window.month.value

dd = datepart(“d”,sSeldate)

thisday = dateserial (yy,mm,1)

set cal(1,1) = t10:set cal(1,2) = t11:set cal(1,3) = t12:set cal(1,4) = t13:set cal(1,5) = t14:set cal(1,6) = t15:set cal(1,7) = t16

set cal(2,1) = t20:set cal(2,2) = t21:set cal(2,3) = t22:set cal(2,4) = t23:set cal(2,5) = t24:set cal(2,6) = t25:set cal(2,7) = t26

set cal(3,1) = t30:set cal(3,2) = t31:set cal(3,3) = t32:set cal(3,4) = t33:set cal(3,5) = t34:set cal(3,6) = t35:set cal(3,7) = t36

set cal(4,1) = t40:set cal(4,2) = t41:set cal(4,3) = t42:set cal(4,4) = t43:set cal(4,5) = t44:set cal(4,6) = t45:set cal(4,7) = t46

set cal(5,1) = t50:set cal(5,2) = t51:set cal(5,3) = t52:set cal(5,4) = t53:set cal(5,5) = t54:set cal(5,6) = t55:set cal(5,7) = t56

set cal(6,1) = t60:set cal(6,2) = t61:set cal(6,3) = t62:set cal(6,4) = t63:set cal(6,5) = t64:set cal(6,6) = t65:set cal(6,7) = t66

for i = 1 to 6

for j = 1 to 7

cal(i,j).innertext = ” “

cal(i,j).style.cursor = “”

cal(i,j).bgcolor=””

next

next

// cal(1,cint(datepart(“w”,thisday))).innertext = 1

// cal(1,cint(datepart(“w”,thisday))).style.cursor=”hand”

//計算選擇缺省日期

lastmm = datepart(“m”,thisday)

nextmm = lastmm + 1

if nextmm= 13 then nextmm = 1

maxday = datepart(“d”,dateadd(“d”,-1,dateserial (yy,nextmm,”1″) ) )

if ddmaxday then dd = maxday

//缺省

i = 1 ‘the line

do until (datepart(“m”,thisday) – lastmm 0)

if datepart (“w”,thisday) = 1 then i = i + 1

cal(i,cint(datepart(“w”,thisday))).innertext = datepart(“d”,thisday)

if thisday=date then

cal(i,cint(datepart(“w”,thisday))).bgcolor=”#A7A4D9″ ‘tt1

cal(i,cint(datepart(“w”,thisday))).style.color=”red”

else

cal(i,cint(datepart(“w”,thisday))).style.color=”black”

end if

if(datepart(“d”,thisday)=dd) then

if thisdaydate then

cal(i,cint(datepart(“w”,thisday))).bgcolor=”blue”

cal(i,cint(datepart(“w”,thisday))).style.color=”white”

end if

dim showday

showday = datepart(“yyyy”,thisday) “-“

if(datepart(“m”,thisday)10) then

showday = showday “0”

end if

showday = showday datepart(“m”,thisday) “-“

if(datepart(“d”,thisday)10) then

showday = showday “0”

end if

showday = showday datepart(“d”,thisday)

window.sel_date.innerText= showday

end if

cal(i,cint(datepart(“w”,thisday))).style.cursor=”hand”

thisday = thisday + 1

loop

for i = 1 to 6

for j = 1 to 7

cal(i,j).style.fontsize = “9pt” ‘” normal small-caps 8pt serif”

next

next

end sub

sub up()

for i = 1 to 6

for j = 1 to 7

if cal(i,j).bgcolor=”#0000ff” then

cal(i,j).bgcolor=””

cal(i,j).style.color=”black”

end if

next

next

if window.month.value = 12 then

if window.year.value 2100 then window.year.value = window.year.value + 1

window.month.value = 1

else

window.month.value = window.month.value + 1

end if

draw()

end sub

sub down ()

for i = 1 to 6

for j = 1 to 7

if cal(i,j).bgcolor=”#0000ff” then

cal(i,j).bgcolor=””

cal(i,j).style.color=”black”

end if

next

next

if window.month.value = 1 then

if window.year.value 1996 then window.year.value = window.year.value – 1

window.month.value = 12

else

window.month.value = window.month.value – 1

end if

draw()

end sub

/script

script ID=”clientEventHandlersVBS” LANGUAGE=”vbscript”

!–

Sub year_onchange

draw()

End Sub

Sub month_onchange

draw()

End Sub

sub init ()

aa = date()

bb = %=parm_year%

if bb = 1950 and bb = 2100 then window.year.value = bb

bb = %=parm_month%

window.month.value = bb

sToday=%=parm_day%

draw ()

end sub

/script

script language=”javascript” for=”t1″ event=”onkeydown”

//Esc退出

var keyDown = event.keyCode

if(keyDown==27){

window.close()

}

/script

/head

body onload=”init” leftmargin=”12″ topmargin=”7″

center

!–font class=’pp’今天是%=cur_date%/fontbr —

table border=”0″ width=”200″ cellspacing=”0″ cellpadding=”1″ bgcolor=”snow” id=”t1″ align=”center”

tr

td colspan=’7′ nowrap

select id=”year” name=”year”

%for (int i=2000; i=2020; i++) {%

option value=%=i%%=i%/option

%}%

/select

select id=”month” name=”month”

%for (int i=1; i=12; i++) {%

option value=%=i%%=i%月/option

%}%

/select      

img src=”../images/arr04.gif” id=”up” language=”vbscript” style=’cursor:hand’ onclick=”down()” accesskey=1 align=”absmiddle”

img src=”../images/arr05.gif” id=”down” language=”vbscript” style=’cursor:hand’ onclick=”up()” accesskey=2 align=”absmiddle”

/td

/tr

tr

td colspan=’7′ height=”5″ /td

/tr

tr bgcolor=”#7975C6″

td align=’center’ class=”cals” height=”23″ align=”absmiddle”日/td

td align=’center’ class=”cals” align=”absmiddle”一/td

td align=’center’ class=”cals” align=”absmiddle”二/td

td align=’center’ class=”cals” align=”absmiddle”三/td

td align=’center’ class=”cals” align=”absmiddle”四/td

td align=’center’ class=”cals” align=”absmiddle”五/td

td align=’center’ class=”cals” align=”absmiddle”六/td

/tr

%for (int i=1; i=6; i++) {%

tr bgcolor=”#e6e6fa”

%for (int j=0; j=6; j++) {%

td align=’center’ id=t%=i%%=j% onclick=”getDate()” ondblclick=”ret()” class=”cals”/td

%}%

/tr

%}%

%String disp=null;%

%if (type.compareTo(“2”)==0) {%

tr

td colspan=’7′ nowrap height=”28″ align=”center” valign=”bottom”

select id=”hour” name=”hour” onchange=’getTime()’

%

for (int i=0; i=23; i++) {

disp=String.valueOf(i);

if (disp.length()==1) disp = “0”+disp;

%

option value=%=disp%%if (i==0) out.print(” selected”);%%=disp%/option

%}%

/selectfont class=’p’時/font

select id=”minute” name=”minute” onchange=’getTime()’

%

for (int i=0; i=59; i++) {

disp=String.valueOf(i);

if (disp.length()==1) disp = “0”+disp;

%

option value=%=disp%%if (i==0) out.print(” selected”);%%=disp%/option

%}%

/selectfont class=’p’分/font

select id=”second” name=”second” onchange=’getTime()’

%

for (int i=0; i=59; i++) {

disp=String.valueOf(i);

if (disp.length()==1) disp = “0”+disp;

%

option value=%=disp%%if (i==0) out.print(” selected”);%%=disp%/option

%}%

/selectfont class=’p’秒/font

/td/tr

%}%

/table

table border=’0′ width=’180′ style=”display:none”

tr

td nowrap

時間:

font color=’red’

span id=’sel_date’ name=’sel_date’/span

span id=’sel_time’ name=’sel_time’/span

/font

/td

/tr

/table

table border=’0′ cellspacing=”0″ cellpadding=”0″

trtd height=”4″/td/tr

trtd align=”absmiddle”img src=”../images/bt_sure.gif” onclick=’ret()’/td/tr

/table

/center

%

String initH=”00″;

String initM=”00″;

String initS=”00″;

if(type.equals(“2”)){

if(parmInitDate==null) parmInitDate=””;

parmInitDate=parmInitDate.trim();

if(parmInitDate.length()10){

initH=parmInitDate.substring(11,13);

initM=parmInitDate.substring(14,16);

initS=parmInitDate.substring(17,19);

}else{

//初始化為當前時間

java.text.SimpleDateFormat sdf=null;

String curTime=””;

try{

sdf=new java.text.SimpleDateFormat(“HH:mm:ss”);

curTime=sdf.format(new java.util.Date());

}catch(Exception e){

curTime=”00:00:00″;

System.out.println(“格式為日期出錯”);

}

initH=curTime.substring(0,2);

initM=curTime.substring(3,5);

initS=curTime.substring(6,8);

}

}

%

script language=”javascript”

var itype=’%=type %’;

var hh=’%=initH %’;

var mm=’%=initM %’;

var ss=’%=initS %’;

if(itype==’2′){

//初始化數據

var objh=document.getElementById(‘hour’);

var objm=document.getElementById(‘minute’);

var objs=document.getElementById(‘second’);

objh.value=hh;

objm.value=mm;

objs.value=ss;

}

/script

/body

/html

在js日曆控件中如何把月和日小於10的自動在前面添加0

自定義過濾器

{{a| xxx}}

Vue.filter(‘xxx’,function(aa){

return aa10?’0’+aa:”+aa;

})

xxx是過濾器的名字

aa 是過濾的那個數據

如果那個數據小於10,則在他前面添加一個0

比如

過濾數據是 9

過濾後變成 09

我用的是vue,邏輯就是這樣

怎樣在網頁中插入日曆控件

日期插件的包為:mydate.js。

1:首先將日期插件的包引入到頁面中

script language=”JavaScript” src=”../Inc/Js/mydate.js”/script

2:設置鼠標點擊事件,當鼠標點擊獲得焦點的時候,觸發事件,調用方法

input type=”text” name=”starttime” onfocus=”MyCalendar.SetDate(this)” value=”?php echo $rq;?”

input type=”text” name=”endtime” onfocus=”MyCalendar.SetDate(this)” value=”?php echo $rq;?”

3:完整頁面代碼

?php

  date_default_timezone_set(“PRC”);

  $nowtime = time();

  $rq = date(“Y-m-d”,$nowtime);

?

html

head

meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ /

meta name=”generator” content=”FFKJ.Net” /

link rev=”MADE” href=”mailto:FFKJ@FFKJ.Net”

title在線–後台/title

link rel=”stylesheet” type=”text/css” href=”../Skins/Admin_Style.Css” /

script language=”JavaScript” src=”../Inc/Js/mydate.js”/script

/head

body

開始時間:input type=”text” name=”starttime” onfocus=”MyCalendar.SetDate(this)” value=”?php echo $rq;?”

結束時間:input type=”text” name=”endtime” onfocus=”MyCalendar.SetDate(this)” value=”?php echo $rq;?”

/body

/html

4:頁面效果:

日曆控件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不同版本可能會不同,調用時看源碼

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/286267.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-22 16:07
下一篇 2024-12-22 16:07

相關推薦

  • Python周杰倫代碼用法介紹

    本文將從多個方面對Python周杰倫代碼進行詳細的闡述。 一、代碼介紹 from urllib.request import urlopen from bs4 import Bea…

    編程 2025-04-29
  • Python字符串寬度不限制怎麼打代碼

    本文將為大家詳細介紹Python字符串寬度不限制時如何打代碼的幾個方面。 一、保持代碼風格的統一 在Python字符串寬度不限制的情況下,我們可以寫出很長很長的一行代碼。但是,為了…

    編程 2025-04-29
  • Python基礎代碼用法介紹

    本文將從多個方面對Python基礎代碼進行解析和詳細闡述,力求讓讀者深刻理解Python基礎代碼。通過本文的學習,相信大家對Python的學習和應用會更加輕鬆和高效。 一、變量和數…

    編程 2025-04-29
  • 倉庫管理系統代碼設計Python

    這篇文章將詳細探討如何設計一個基於Python的倉庫管理系統。 一、基本需求 在着手設計之前,我們首先需要確定倉庫管理系統的基本需求。 我們可以將需求分為以下幾個方面: 1、庫存管…

    編程 2025-04-29
  • Python滿天星代碼:讓編程變得更加簡單

    本文將從多個方面詳細闡述Python滿天星代碼,為大家介紹它的優點以及如何在編程中使用。無論是剛剛接觸編程還是資深程序員,都能從中獲得一定的收穫。 一、簡介 Python滿天星代碼…

    編程 2025-04-29
  • 寫代碼新手教程

    本文將從語言選擇、學習方法、編碼規範以及常見問題解答等多個方面,為編程新手提供實用、簡明的教程。 一、語言選擇 作為編程新手,選擇一門編程語言是很關鍵的一步。以下是幾個有代表性的編…

    編程 2025-04-29
  • Python實現簡易心形代碼

    在這個文章中,我們將會介紹如何用Python語言編寫一個非常簡單的代碼來生成一個心形圖案。我們將會從安裝Python開始介紹,逐步深入了解如何實現這一任務。 一、安裝Python …

    編程 2025-04-29
  • 怎麼寫不影響Python運行的長段代碼

    在Python編程的過程中,我們不可避免地需要編寫一些長段代碼,包括函數、類、複雜的控制語句等等。在編寫這些代碼時,我們需要考慮代碼可讀性、易用性以及對Python運行性能的影響。…

    編程 2025-04-29
  • 北化教務管理系統介紹及開發代碼示例

    本文將從多個方面對北化教務管理系統進行介紹及開發代碼示例,幫助開發者更好地理解和應用該系統。 一、項目介紹 北化教務管理系統是一款針對高校學生和教職工的綜合信息管理系統。系統實現的…

    編程 2025-04-29
  • Python愛心代碼動態

    本文將從多個方面詳細闡述Python愛心代碼動態,包括實現基本原理、應用場景、代碼示例等。 一、實現基本原理 Python愛心代碼動態使用turtle模塊實現。在繪製一個心形的基礎…

    編程 2025-04-29

發表回復

登錄後才能評論