JS effect code--Calendar Builder

Source: Internet
Author: User
Tags getdate

 

  <head> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "> <title> web Effects | linkweb.cn/js|---Calendar builder </title> </head>   <body>   <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 = "";} else {Myelement.color = Togglecolor    } else if (myelement.id = = "Calcell") {for (var i in Myelement.child ren) {if (myelement.children[i].id = = "Caldatetext") {if (Myelement.children[i].color = = Togglecolor) {Myelement.childr En[i].color = "";} else {Myelement.children[i].color = Togglecolor            }         &NBSP}      } &NBSp &NBSP}} function Fsetselectedday (myelement) {if (myelement.id = = "Calcell") {if (!isnan (parseint) Caldatetext "].innertext)") {Myelement.bgcolor = "#c0c0c0"; objprevelement.bgcolor = ""; Document.all.calSelectedDate.value = parseint (myelement.children["Caldatetext"].innertext); Objprevelement = myelement;      }   &NBSP}} 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] = "Sunday"; amonth[0][1] = "Monday"; amonth[0][2] = "TuesDay "; AMONTH[0][3] = "Wednesday"; AMONTH[0][4] = "Thursday"; AMONTH[0][5] = "Friday"; AMONTH[0][6] = "Saturday"; else if (Idaystyle = 1) {amonth[0][0] = "Sun"; amonth[0][1] = "Mon"; amonth[0][2] = "Tue"; amonth[0][3] = "Wed"; amont H[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++;      }    } ret Urn AMonth; function fdrawcal (iyear, Imonth, Icellwidth, Icellheight, Sdatetextsize, Sdatetextweight, Idaystyle) {var myMonth; myMo Nth = fbuildcal (Iyear, Imonth, Idaystyle); document.write ("<table border= ' 1 ' >") document.write ("<tr>"); document.write ("<td align= ' center ' style= ')font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][0] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][1] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][2] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][3] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][4] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][5] + "</td>"); document.write ("<td align= ' center ' style= ' font-family:arial; font-size:12px; Font-weight:bold ' > ' + mymonth[0][6] + "</td>"); document.write ("</tr>"); for (w = 1; w < 7 w++) {document.write (' <tr> ') for(d = 0; d < 7; d++) {document.write ("<td align= ' left ' valign= ' top ' width= '" + icellwidth + "' height= '" + icellheight + "' Id=calcell styl E= ' Cursor:hand ' onmouseover= ' Ftogglecolor (this) ' onmouseout= ' Ftogglecolor (This) ' Onclick=fsetselectedday (This) > "); 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 ] + "</font>"); else {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) > </font> " ); } document.write ("</td>")} document.write ("</tr>"); } document.write ("</table>")} function Fupdatecal (Iyear, imonth) {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 = "";           {     }   &NBSP}}//End--> </script>   Step two: put the following code Join <body> area: <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= "POST" action= "" > <input type= "Hidden" name= "calselecteddate" value= "" >   <table border= "1" > <tr> ≪td> <select name= "tbselmonth" Onchange= ' fupdatecal (FrmCalendarSample.tbSelYear.value, FrmCalendarSample.tbSelMonth.value) ' > <option value= "1" >January</option> <option value= "2" > February</option> <option value= "3" >March</option> <option value= "4" >April</option> <option value= "5" >May</option> <option value= "6" >June</option> <option value= "7" >july </option> <option value= "8" >August</option> <option value= "9" >September</option> < Option value= "Ten" >October</option> <option value= "One" >November</option> <option value= "12" >December</option> </select>    <select name= "tbselyear" Onchange= ' fupdatecal ( FrmCalendarSample.tbSelYear.value, FrmCalendarSample.tbSelMonth.value) ' > <option value= 1998 ' >1998</ Option> <option value= "1999" >1999</option> <option "value=" >2000</option> <option VaLue= "2001" >2001</option> <option value= "2002" >2002</option> <option value= "2003" >2003 </option> <option value= "," >2004</option> </select> </td> </tr> <tr> <td> <script language= "JavaScript" > var dcurdate = new Date (); Fdrawcal (Dcurdate.getfullyear (), Dcurdate.getmonth () +1, "12px", "bold", 1); </script> </td> </tr> </table> </form>  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.