主题:急在线等,这段js日历程序怎么得到年月日的值!拜托了!
就是说怎么让跳转的页面取到年月日的值,最好能直接在地址栏里显示!
谁来帮帮我,我已经想了2天了,拜托了!万分感谢了!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.bg{
color: #FFFFFF;
cursor: default;
background-color: #0099FF;
font-family:Arial;
font-size:12px;
font-weight:bold;
}
.a1{
font-family: "宋体";
font-size: 12px;
color: #000000;
cursor: default;
}
.bg1{
background-color:#FF6600
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var dDate = new Date();
var dCurMonth = dDate.getMonth();
var dCurDayOfMonth = dDate.getDate();
var dCurYear = dDate.getFullYear();
var objPrevElement = new Object();
function fToggleColor(myElement)
{
var toggleColor = "#ff0000";
if (myElement.id == "calDateText")
{
if (myElement.color == toggleColor)
{
myElement.color = toggleColor;
}
else
{
myElement.color = "";
}
}
else if (myElement.id == "calCell")
{
for (var i in myElement.children)
{
if (myElement.children[i].id == "calDateText")
{
if (myElement.children[i].color == toggleColor)
{
myElement.children[i].color = "";
}
else
{
myElement.children[i].color = toggleColor;
}
}
}
}
}
function fSetSelectedDay(myElement, URL)
{
if (myElement.id == "calCell")
{
if (!isNaN(parseInt(myElement.children["calDateText"].innerText)))
{
myElement.bgColor = "#0099FF";
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);
objPrevElement = myElement;
//alert(myElement.children["calDateText"].innerText);
window.open(URL,"");
}
}
}
function fGetDaysInMonth(iMonth, iYear)
{
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function fBuildCal(iYear, iMonth, iDayStyle)
{
var aMonth = new Array();
aMonth[0] = new Array(7);
aMonth[1] = new Array(7);
aMonth[2] = new Array(7);
aMonth[3] = new Array(7);
aMonth[4] = new Array(7);
aMonth[5] = new Array(7);
aMonth[6] = new Array(7);
var dCalDate = new Date(iYear, iMonth-1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
var iVarDate = 1;
var i, d, w;
if (iDayStyle == 2)
{
aMonth[0][0] = "日";
aMonth[0][1] = "一";
aMonth[0][2] = "二";
aMonth[0][3] = "三";
aMonth[0][4] = "四";
aMonth[0][5] = "五";
aMonth[0][6] = "六";
}
else if (iDayStyle == 1)
{
aMonth[0][0] = "Sun";
aMonth[0][1] = "Mon";
aMonth[0][2] = "Tue";
aMonth[0][3] = "Wed";
aMonth[0][4] = "Thu";
aMonth[0][5] = "Fri";
aMonth[0][6] = "Sat";
}
else
{
aMonth[0][0] = "Su";
aMonth[0][1] = "Mo";
aMonth[0][2] = "Tu";
aMonth[0][3] = "We";
aMonth[0][4] = "Th";
aMonth[0][5] = "Fr";
aMonth[0][6] = "Sa";
}
for (d = iDayOfFirst; d < 7; d++)
{
aMonth[1][d] = iVarDate;
iVarDate++;
}
for (w = 2; w < 7; w++)
{
for (d = 0; d < 7; d++)
{
if (iVarDate <= iDaysInMonth)
{
aMonth[w][d] = iVarDate;
iVarDate++;
}
}
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle, URL)
{
var myMonth;
myMonth = fBuildCal(iYear, iMonth, iDayStyle);
document.write("<table cellspacing='1' bgcolor='#FFFFFF'>")
document.write("<tr height='18'>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][0] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][1] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][2] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][3] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][4] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][5] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][6] + "</td>");
document.write("</tr>");
for (w = 1; w < 7; w++)
{
document.write("<tr>");
/* if(w = 6)
{
}
*/ for (d = 0; d < 7; d++)
{
document.write("<td align='center' valign='top' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this,'"+ URL +"') bgcolor='#F3F3F3'>");
if (!isNaN(myMonth[w][d]))
{
document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</span></font>");
}
else
{
document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)'>&nbsp;</span></font>");
}
document.write("</td>")
}
document.write("</tr>");
}
document.write("</table>")
}
function fUpdateCal(iYear, iMonth, opid)
{
myMonth = fBuildCal(iYear, iMonth);
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = "";
for (w = 1; w < 7; w++)
{
for (d = 0; d < 7; d++)
{
if (!isNaN(myMonth[w][d]))
{
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
}
else
{
calDateText[((7*w)+d)-7].innerText = " ";
}
}
}
}
// End -->
function num(n1,n2)
{
for($i=n1;$i<=n2;$i++)
{
document.write('<option value="'+$i+'">'+$i+'</option>');
}
}
function getSelectedValue(name){
var obj=document.getElementById(name);
return obj.value; //如此简单,直接用其对象的value属性便可获取到
}
</script>
</head>
<body>
<script language="JavaScript" for="window" event="onload">
<!-- Begin
var dCurDate = new Date();
frmCalendarSample.tbSelMonth.options[dCurDate.getMonth()].selected = true;
for (i = 0; i < frmCalendarSample.tbSelYear.length; i++)
if (frmCalendarSample.tbSelYear.options[i].value == dCurDate.getFullYear()) frmCalendarSample.tbSelYear.options[i].selected = true;
// End -->
</script>
<form name="frmCalendarSample" method="get">
<input type="hidden" name="calSelectedDate" value="">
<table cellspacing="1" bgcolor="#0099FF">
<tr align="center" valign="middle">
<td bgcolor="#FFFFFF" class="a1">
<script language="JavaScript">
var dCurDate = new Date();
document.write("今天是"+dCurDate.getFullYear()+"年"+(dCurDate.getMonth()+1)+"月"+dCurDate.getDate()+"日!");
</script>
</td></tr>
<tr><td bgcolor="#FFFFFF">
<table width="100%" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" bgcolor="#0099FF">
<select name="tbSelYear" onChange="fUpdateCal(document.frmCalendarSample.tbSelYear.value, document.frmCalendarSample.tbSelMonth.value,tbSelYear)" onclick="document.ye.value=getSelectedValue('tbSelYear')">
<script>num(2003,2012);</script>
</select>
</td>
<td bgcolor="#0099FF" align="center">
<select name="tbSelMonth" onChange="fUpdateCal(document.frmCalendarSample.tbSelYear.value, document.frmCalendarSample.tbSelMonth.value,tbSelMonth)">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
</tr></table>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">
<input name="ye" id="ye" type="hidden"/>
<script language="JavaScript">
//fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 15, 14, "12px", "bold", 2, "04.php");document.getElementById('tbSelYear').innerText
fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 15, 14, "12px", "bold", 2, "02.php?y="+document.frmCalendarSample.ye.value+"&m="+document.frmCalendarSample.tbSelMonth.value+"&d=");
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
谁来帮帮我,我已经想了2天了,拜托了!万分感谢了!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.bg{
color: #FFFFFF;
cursor: default;
background-color: #0099FF;
font-family:Arial;
font-size:12px;
font-weight:bold;
}
.a1{
font-family: "宋体";
font-size: 12px;
color: #000000;
cursor: default;
}
.bg1{
background-color:#FF6600
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var dDate = new Date();
var dCurMonth = dDate.getMonth();
var dCurDayOfMonth = dDate.getDate();
var dCurYear = dDate.getFullYear();
var objPrevElement = new Object();
function fToggleColor(myElement)
{
var toggleColor = "#ff0000";
if (myElement.id == "calDateText")
{
if (myElement.color == toggleColor)
{
myElement.color = toggleColor;
}
else
{
myElement.color = "";
}
}
else if (myElement.id == "calCell")
{
for (var i in myElement.children)
{
if (myElement.children[i].id == "calDateText")
{
if (myElement.children[i].color == toggleColor)
{
myElement.children[i].color = "";
}
else
{
myElement.children[i].color = toggleColor;
}
}
}
}
}
function fSetSelectedDay(myElement, URL)
{
if (myElement.id == "calCell")
{
if (!isNaN(parseInt(myElement.children["calDateText"].innerText)))
{
myElement.bgColor = "#0099FF";
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);
objPrevElement = myElement;
//alert(myElement.children["calDateText"].innerText);
window.open(URL,"");
}
}
}
function fGetDaysInMonth(iMonth, iYear)
{
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function fBuildCal(iYear, iMonth, iDayStyle)
{
var aMonth = new Array();
aMonth[0] = new Array(7);
aMonth[1] = new Array(7);
aMonth[2] = new Array(7);
aMonth[3] = new Array(7);
aMonth[4] = new Array(7);
aMonth[5] = new Array(7);
aMonth[6] = new Array(7);
var dCalDate = new Date(iYear, iMonth-1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
var iVarDate = 1;
var i, d, w;
if (iDayStyle == 2)
{
aMonth[0][0] = "日";
aMonth[0][1] = "一";
aMonth[0][2] = "二";
aMonth[0][3] = "三";
aMonth[0][4] = "四";
aMonth[0][5] = "五";
aMonth[0][6] = "六";
}
else if (iDayStyle == 1)
{
aMonth[0][0] = "Sun";
aMonth[0][1] = "Mon";
aMonth[0][2] = "Tue";
aMonth[0][3] = "Wed";
aMonth[0][4] = "Thu";
aMonth[0][5] = "Fri";
aMonth[0][6] = "Sat";
}
else
{
aMonth[0][0] = "Su";
aMonth[0][1] = "Mo";
aMonth[0][2] = "Tu";
aMonth[0][3] = "We";
aMonth[0][4] = "Th";
aMonth[0][5] = "Fr";
aMonth[0][6] = "Sa";
}
for (d = iDayOfFirst; d < 7; d++)
{
aMonth[1][d] = iVarDate;
iVarDate++;
}
for (w = 2; w < 7; w++)
{
for (d = 0; d < 7; d++)
{
if (iVarDate <= iDaysInMonth)
{
aMonth[w][d] = iVarDate;
iVarDate++;
}
}
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle, URL)
{
var myMonth;
myMonth = fBuildCal(iYear, iMonth, iDayStyle);
document.write("<table cellspacing='1' bgcolor='#FFFFFF'>")
document.write("<tr height='18'>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][0] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][1] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][2] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][3] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][4] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][5] + "</td>");
document.write("<td align='center' valign='middle' class='bg'>" + myMonth[0][6] + "</td>");
document.write("</tr>");
for (w = 1; w < 7; w++)
{
document.write("<tr>");
/* if(w = 6)
{
}
*/ for (d = 0; d < 7; d++)
{
document.write("<td align='center' valign='top' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this,'"+ URL +"') bgcolor='#F3F3F3'>");
if (!isNaN(myMonth[w][d]))
{
document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</span></font>");
}
else
{
document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)'>&nbsp;</span></font>");
}
document.write("</td>")
}
document.write("</tr>");
}
document.write("</table>")
}
function fUpdateCal(iYear, iMonth, opid)
{
myMonth = fBuildCal(iYear, iMonth);
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = "";
for (w = 1; w < 7; w++)
{
for (d = 0; d < 7; d++)
{
if (!isNaN(myMonth[w][d]))
{
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
}
else
{
calDateText[((7*w)+d)-7].innerText = " ";
}
}
}
}
// End -->
function num(n1,n2)
{
for($i=n1;$i<=n2;$i++)
{
document.write('<option value="'+$i+'">'+$i+'</option>');
}
}
function getSelectedValue(name){
var obj=document.getElementById(name);
return obj.value; //如此简单,直接用其对象的value属性便可获取到
}
</script>
</head>
<body>
<script language="JavaScript" for="window" event="onload">
<!-- Begin
var dCurDate = new Date();
frmCalendarSample.tbSelMonth.options[dCurDate.getMonth()].selected = true;
for (i = 0; i < frmCalendarSample.tbSelYear.length; i++)
if (frmCalendarSample.tbSelYear.options[i].value == dCurDate.getFullYear()) frmCalendarSample.tbSelYear.options[i].selected = true;
// End -->
</script>
<form name="frmCalendarSample" method="get">
<input type="hidden" name="calSelectedDate" value="">
<table cellspacing="1" bgcolor="#0099FF">
<tr align="center" valign="middle">
<td bgcolor="#FFFFFF" class="a1">
<script language="JavaScript">
var dCurDate = new Date();
document.write("今天是"+dCurDate.getFullYear()+"年"+(dCurDate.getMonth()+1)+"月"+dCurDate.getDate()+"日!");
</script>
</td></tr>
<tr><td bgcolor="#FFFFFF">
<table width="100%" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" bgcolor="#0099FF">
<select name="tbSelYear" onChange="fUpdateCal(document.frmCalendarSample.tbSelYear.value, document.frmCalendarSample.tbSelMonth.value,tbSelYear)" onclick="document.ye.value=getSelectedValue('tbSelYear')">
<script>num(2003,2012);</script>
</select>
</td>
<td bgcolor="#0099FF" align="center">
<select name="tbSelMonth" onChange="fUpdateCal(document.frmCalendarSample.tbSelYear.value, document.frmCalendarSample.tbSelMonth.value,tbSelMonth)">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
</tr></table>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">
<input name="ye" id="ye" type="hidden"/>
<script language="JavaScript">
//fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 15, 14, "12px", "bold", 2, "04.php");document.getElementById('tbSelYear').innerText
fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 15, 14, "12px", "bold", 2, "02.php?y="+document.frmCalendarSample.ye.value+"&m="+document.frmCalendarSample.tbSelMonth.value+"&d=");
</script>
</td>
</tr>
</table>
</form>
</body>
</html>