Jump to content
  • 0

Календарь


danila_omega
 Share

Question

Есть календарь

Вот скрипт:

<head>

<script language="javascript">

var dDate = new Date();

var dCurMonth = dDate.getMonth();

var dCurDayOfMonth = dDate.getDate();

var dCurYear = dDate.getFullYear();

var objPrevElement = new Object();

var bgcolor

var webgcolor

var wecolor

var nwecolor

var tbgcolor

var ntbgcolor

var sbgcolor

function fToggleColor(myElement)

{

var toggleColor = "#ff0000";

if (myElement.id == "calDateText")

{

if (myElement.color == toggleColor)

{

myElement.color = "";

}

else

{

myElement.color = toggleColor;

}

}

else

if ((myElement.id == "calCell") || (myElement.id == "calTodayCell"))

{

for (var i in myElement.children)

{

if (myElement.children.id == "calDateText")

{

if (myElement.children.color == toggleColor)

{

myElement.children.color = "";

}

else

{

myElement.children.color = toggleColor;

}

}

}

}

}

function fSetSelectedDay(myElement)

{

if (myElement.id == "calCell")

{

if (!isNaN(parseInt(myElement.children["calDateText"].innerText)))

{

myElement.bgColor = sbgcolor;

objPrevElement.bgColor = ntbgcolor;

document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);

objPrevElement = myElement;

}

}

}

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 (iDayOfFirst==0)

{

iDayOfFirst=6

}

else

{

iDayOfFirst=iDayOfFirst-1

}

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] = "Пон";

aMonth[0][1] = "Вт";

aMonth[0][2] = "Ср";

aMonth[0][3] = "Чт";

aMonth[0][4] = "Пт";

aMonth[0][5] = "Сб";

aMonth[0][6] = "Вск";

}

else

{

aMonth[0][0] = "Пн";

aMonth[0][1] = "Вт";

aMonth[0][2] = "Ср";

aMonth[0][3] = "Чт";

aMonth[0][4] = "Пт";

aMonth[0][5] = "Сб";

aMonth[0][6] = "Вс";

}

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, ibgcolor, iwebgcolor, inwecolor, iwecolor, itbgcolor, intbgcolor, isbgcolor)

{

bgcolor = ibgcolor;

webgcolor = iwebgcolor;

wecolor = iwecolor;

nwecolor = inwecolor;

tbgcolor = itbgcolor;

ntbgcolor = intbgcolor;

sbgcolor = isbgcolor;

var myMonth;

myMonth = fBuildCal(iYear, iMonth, iDayStyle);

document.write("<table border='0'>")

document.write("<tr>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ bgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ nwecolor +"'>" + myMonth[0][0] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ bgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ nwecolor +"'>" + myMonth[0][1] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ bgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ nwecolor +"'>" + myMonth[0][2] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ bgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ nwecolor +"'>" + myMonth[0][3] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ bgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ nwecolor +"'>" + myMonth[0][4] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ webgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ wecolor +"'>" + myMonth[0][5] + "</td>");

document.write("<td align='center' style='BACKGROUND-COLOR:"+ webgcolor +";FONT-FAMILY:Arial;FONT-SIZE:12px;FONT-WEIGHT:bold;COLOR:"+ wecolor +"'>" + myMonth[0][6] + "</td>");

document.write("</tr>");

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

{

document.write("<tr>")

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

{

if (myMonth[w][d]==dCurDayOfMonth)

{

document.write("<td id=calTodayCell bgcolor='"+ tbgcolor +"' align='center' valign='center' width='" + iCellWidth + "' height='" + iCellHeight + "' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");

}

else

{

document.write("<td id=calCell bgcolor='"+ ntbgcolor +"' align='center' valign='center' width='" + iCellWidth + "' height='" + iCellHeight + "' style='CURSOR:Hand;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");

}

if (!isNaN(myMonth[w][d]))

{

document.write("<font id=calDateText onclick=fSetSelectedDay(this)>" + myMonth[w][d]);

}

else

{

document.write("<font id=calDateText onclick=fSetSelectedDay(this)>");

}

document.write("</td>")

}

document.write("</tr>");

}

document.write("</table>")

}

function fUpdateCal(iYear, iMonth)

{

myMonth = fBuildCal(iYear, iMonth);

objPrevElement.bgColor = ntbgcolor;

if (((iMonth-1)==dCurMonth) && (iYear==dCurYear))

{

calTodayCell.bgColor = tbgcolor

}

else

{

calTodayCell.bgColor = ntbgcolor

}

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 = " ";

}

}

}

}

-->

</script>

<!-- ОКОНЧАНИЕ -->

</head>

<body>

<!--

Вставить текст в необходимое место Вашей страницы

-->

<!-- НАЧАЛО -->

<script language="JavaScript" for=window event=onload>

<!--

var dCurDate = new Date();

frmCalendar.tbSelMonth.options[dCurDate.getMonth()].selected = true;

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

if (frmCalendar.tbSelYear.options.value == dCurDate.getFullYear())

frmCalendar.tbSelYear.options.selected = true;

-->

</script>

<form name="frmCalendar" method="post" action="">

<input type="hidden" name="calSelectedDate" value="">

<table border="2" bgcolor="white">

<tr>

<td align=center>

<select name="tbSelMonth" onchange='fUpdateCal(frmCalendar.tbSelYear.value, frmCalendar.tbSelMonth.value)'>

<option value="1">Январь</option>

<option value="2">Февраль</option>

<option value="3">Март</option>

<option value="4">Апрель</option>

<option value="5">Май</option>

<option value="6">Июнь</option>

<option value="7">Июль</option>

<option value="8">Август</option>

<option value="9">Сентябрь</option>

<option value="10">Октябрь</option>

<option value="11">Ноябрь</option>

<option value="12">Декабрь</option>

</select>

<select name="tbSelYear" onchange='fUpdateCal(frmCalendar.tbSelYear.value, frmCalendar.tbSelMonth.value)'>

<option value="2012">2012</option>

<option value="2013">2013</option>

<option value="2014">2014</option>

<option value="2015">2015</option>

<option value="2016">2016</option>

</select>

</td>

</tr>

<tr>

<td>

<script language="JavaScript">

var dCurDate = new Date();

fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 30, 16, "12px", "bold", 3, "gray", "red", "white", "white", "red", "silver", "#D6D6D6");

</script>

</td>

</tr>

</table>

</form>

<!-- ОКОНЧАНИЕ -->

Подскажите пожалуйста что дописать?

Необходимо:

чтобы на любое число я мог приписать ссылку и она (дата) подсвечивалась в календаре а при нажатии на дату пользователь перемещался по ссылке!

Вот картинка

http://itmages.ru/image/view/796241/a0a9e918

20 число тут выделяется но не ссылка и до того как я на него навожу она не подсвечивается.

Необходимо чтобы до наведения она подсвечивалась и при клике по ней я переходил на указанный адрес

Edited by danila_omega
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy