Tuesday, March 24, 2009

Creating Calender Using Java Script

Following is the JavaScript Code for the HTML File....the whole file is posted as an attachment please have a look on that for detailed Information...
Script in Head Tag
[code]
function showseldate(obj)
{
if(obj.value!="")
{
seldate.innerHTML="<b>" + parseInt(document.calform.drpmonth.value)+1 + "/" + obj.value + "/" + document.calform.drpyear.value + "</b>";
} }
function changecalendar()
{
var m,y;
m=document.calform.drpmonth.value;
y=document.calform.drpyear.value;
displaycalendar(m,y);
}
function showcurcal()
{
var dt=new Date();
var m,y; m=dt.getMonth(); y=dt.getFullYear();
displaycalendar(m,y);
}
function displaycalendar(m,y)
{
var nod=numofdays(parseInt(m)+1,y);
var wd; var dt=new Date();
var curday=dt.getDate(); dt.setDate(1);
dt.setMonth(m); dt.setFullYear(y); wd=dt.getDay();
clear();
for(var i=1;i<=nod;i++)
{
document.calform.txtday[wd].value=i;
if(i==curday)
{
document.calform.txtday[wd].style.backgroundColor="red";
document.calform.txtday[wd].style.color="white";
}
wd++;
}
}
function clear()
{
for(var i=0;i<42;i++)
{
document.calform.txtday[i].value="";
} }
[/code]
In Body[code]
for(var i=1;i<=6;i++)
{
document.write("tr bgcolor='#FFCC00' >");
for(var j=1;j<=7;j++)
{
document.write("td><div align='center'><input name='txtday' type='text' size='3' onclick='showseldate(this)' readonly></div></td>");
} document.write("</tr>"); }[/code]


--
Thanks and Regards
Meetu Choudhary

1 comment:

  1. its nice but you should also post the html tag of page and calling this javascript function..so it will be useful to newcomer also and anyone can easily undersatnd who has difficulty to use java script and html tag and control...

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com