怎么获取数据库中的数据,然后放到fullcalendar.js这个日历插件上去

怎么获取数据库中的数据,然后放到fullcalendar.js这个日历插件上去,第1张

不知道你用什么框架开发的,一般都是在Controller或Action里面数据库里面的数据读出来,然后setAttribute里面把数据set到页面,在日历插件上的value值引用即可。

<%@ page contentType="text/htmlcharset=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/htmlcharset=gb2312">

<META name="GENERATOR" content="IBM WebSphere Studio">

<style>

SELECT {FONT-SIZE: 9ptLINE-HEIGHT: 11pt}

TEXTAREA {FONT-SIZE: 9ptLINE-HEIGHT: 11pt}

INPUT {FONT-SIZE: 9ptLINE-HEIGHT: 11pt}

TD {FONT-SIZE: 9ptLINE-HEIGHT: 11pt}

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

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

.cals{font-family: "Arial"color:#000000font-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_month<10?("0"+String.valueOf(cur_month)):String.valueOf(cur_month)) + "-"

+ (cur_day<10?("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 dd>maxday 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 thisday<>date 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%></font><br> -->

<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=2000i<=2020i++) {%>

<option value=<%=i%>><%=i%></option>

<%}%>

</select>

<select id="month" name="month">

<%for (int i=1i<=12i++) {%>

<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=1i<=6i++) {%>

<tr bgcolor="#e6e6fa">

<%for (int j=0j<=6j++) {%>

<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=0i<=23i++) {

disp=String.valueOf(i)

if (disp.length()==1) disp = "0"+disp

%>

<option value=<%=disp%><%if (i==0) out.print(" selected")%>><%=disp%></option>

<%}%>

</select><font class='p'>时</font>

<select id="minute" name="minute" onchange='getTime()'>

<%

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

disp=String.valueOf(i)

if (disp.length()==1) disp = "0"+disp

%>

<option value=<%=disp%><%if (i==0) out.print(" selected")%>><%=disp%></option>

<%}%>

</select><font class='p'>分</font>

<select id="second" name="second" onchange='getTime()'>

<%

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

disp=String.valueOf(i)

if (disp.length()==1) disp = "0"+disp

%>

<option value=<%=disp%><%if (i==0) out.print(" selected")%>><%=disp%></option>

<%}%>

</select><font 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" >

<tr><td height="4"></td></tr>

<tr><td 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>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6733010.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-27
下一篇 2023-03-27

发表评论

登录后才能评论

评论列表(0条)

保存