Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2009, 09:40
Avatar de tampon
tampon
 
Fecha de Ingreso: julio-2009
Mensajes: 420
Antigüedad: 15 años, 6 meses
Puntos: 0
Configurar calendario

Hola a todos, hice una pregunta en un post anterior pero no tenia que ver nada con al pregunta inicial, asi que empieso un nuevo tema ojala me puedan ayudar con este, ya que es bien importante para mi y no eh podido dar con la solucion, tal vez alguna persona con mas experiencia pueda echarme una mano, se lo agradeceria.

este es el codigo:

Código js:
Ver original
  1. <script language="JavaScript">
  2.  
  3. var gdCtrl = new Object();
  4. var gcGray = "#BEBEBE";
  5. var gcToggle = "#CCCCCC";
  6. var gcBG = "#FFFFFF";
  7. var gcdarkblue= "#CC0000";
  8. var gdCurDate = new Date();
  9. var giYear = gdCurDate.getFullYear();
  10. var giMonth = gdCurDate.getMonth()+1;
  11. var giDay = gdCurDate.getDate();
  12. var VicPopCal = new Object();
  13. var diafechado;
  14. var mesfechado;
  15. var yearfechado;
  16. var overCerrar = "#CEC6A6";
  17.  
  18. function fPopCalendar(popCtrl, dateCtrl, popCal, year, month, day){
  19.   //parent.event.cancelBubble=true;
  20.   VicPopCal = popCal;
  21.   gdCtrl = dateCtrl;
  22.   diafechado=day;
  23.   mesfechado=month;
  24.   yearfechado=year;
  25.   fSetYearMon(year, month);
  26.   var point = fGetXY(popCtrl);
  27.    with (VicPopCal.style) {
  28.     left = point.x+154+'px';
  29.     top  = point.y-89+'px';
  30.     visibility = 'visible';
  31.   }
  32.   VicPopCal.focus();
  33.   // in order to make compatible with IE4.x , here I cut two line below off.
  34.   // VicPopCal.all("popFrame").width=document.all("popTable").offsetWidth;
  35.   // VicPopCal.all("popFrame").height=document.all("popTable").offsetHeight;
  36.   // if u only target on IE5.x, uncommented them and delete the width&height prop in <IFrame> tag
  37.   // thus you will find the 3rd para in fDrawCal() now works perfectly.
  38. }
  39.  
  40. function cerrar(){
  41.     VicPopCal.style.visibility = "hidden";
  42. }
  43.  
  44. function fSetDate(iYear, iMonth, iDay){
  45.     var meses = Array('', 'Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');
  46.     iMonth = meses[parseInt(iMonth)];
  47.    
  48.     if (iDay<10)
  49.         iDay = "0"+iDay;
  50.        
  51.     gdCtrl.value = iDay+"/"+iMonth+"/"+iYear;  
  52.  
  53.     VicPopCal.style.visibility = "hidden";
  54. }
  55.  
  56. function fSetSelected(aCell, num){
  57.   var iOffset = 0;
  58.   var iYear = parseInt(window.document.getElementById('tbSelYear').value);
  59.   var iMonth = parseInt(window.document.getElementById('tbSelMonth').value);
  60.  
  61.   aCell.bgColor =gcBG;
  62.   with (window.document.getElementById("cellText["+num+"]")) {
  63.   //with (aCell.children[ "cellText["+num+"]" ]) {
  64.   //    var iDay = parseInt(innerText);
  65. //  var iDay = parseInt(window.document.getElementById("cellText["+num+"]").value);}
  66. var browser=navigator.appName;
  67. if (browser=="Microsoft Internet Explorer"){
  68.  var iDay = window.document.getElementById("cellText["+num+"]").innerText;
  69. }
  70. else {
  71.  var iDay = parseInt(innerHTML);
  72. }
  73.   }
  74.   if (!isNaN(iDay))
  75.     if (giYear<iYear)
  76.         if (giMonth>iMonth)
  77.             fSetDate(iYear, iMonth, iDay);
  78.         else {
  79.             if (giMonth==iMonth) {
  80.                 if (giDay>=iDay)
  81.                     fSetDate(iYear, iMonth, iDay);
  82.             }
  83.         }
  84.     else
  85.         if (giYear==iYear)
  86.                 if (giMonth<iMonth)
  87.                     fSetDate(iYear, iMonth, iDay);
  88.                 else
  89.                     if (giMonth==iMonth)
  90.                         if (giDay<=iDay)
  91.                             fSetDate(iYear, iMonth, iDay);
  92. }
  93.  
  94. function Point(iX, iY){
  95.     this.x = iX-162;
  96.     this.y = iY+23;
  97. }
  98.  
  99. function fBuildCal(iYear, iMonth) {
  100.   var aMonth=new Array();
  101.   for(i=1;i<7;i++)
  102.     aMonth[i]=new Array(i);
  103.  
  104.   var dCalDate=new Date(iYear, iMonth-1, 1);
  105.   var iDayOfFirst=dCalDate.getDay();
  106.   var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
  107.   var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
  108.   var iDate = 1;
  109.   var iNext = 1;
  110.  
  111.  for (d = 0; d < 7; d++)
  112.     aMonth[1][d] = (d<iDayOfFirst)?" ":iDate++;
  113.   for (w = 2; w < 7; w++)
  114.     for (d = 0; d < 7; d++)
  115.         aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:" ";
  116.   return aMonth;
  117. }
  118.  
  119. function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize) {
  120.   var WeekDay = new Array("D","L","M","M","J","V","S");
  121.   var styleTD = " bgcolor='"+gcBG+"' width='"+iCellWidth+"' bordercolor='"+gcBG+"' valign='middle' align='center'  class='calendario' ";
  122.   with (document) {
  123.     write("<tr>");
  124.     for(i=0; i<7; i++)
  125.         write("<td "+styleTD+" ><b>" + WeekDay[i] + "</b></td>");
  126.     write("</tr>");
  127.  
  128.     for (w = 1; w < 7; w++) {
  129.         write("<tr>");
  130.         for (d = 0; d < 7; d++) {
  131.         num=(7*w)+d;
  132.                  write("<td id=calCell"+(w+d)+ " "+styleTD+"' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick=fSetSelected(calCell"+(w+d)+ ","+num+")> ");
  133.             write("<font id=cellText["+num+"] ></font>");
  134.             write("</td>")
  135.         }
  136.         write("</tr>");
  137.     }
  138.   }
  139. }
  140.  
  141. function fUpdateCal(iYear, iMonth) {
  142.   myMonth = fBuildCal(iYear, iMonth);
  143.   var i = 0;
  144.   for (w = 0; w < 6; w++)
  145.     for (d = 0; d < 7; d++)
  146.     with (window.document.getElementById("cellText["+((7*(w+1))+d)+"]")) {
  147.    
  148.         //with (cellText[(7*w)+d]) {
  149.             if (myMonth[w+1][d]<0) {
  150.                 color = gcGray;
  151.                 innerHTML  = -myMonth[w+1][d];
  152.             }else{
  153.                
  154.     if (giYear<iYear)
  155.         if (giMonth>iMonth) {
  156.             color = ((d==0)||(d==6))?"#AA0000":"black";
  157.             onClick = "javascript:";
  158.             innerHTML  =myMonth[w+1][d];
  159.         }
  160.         else {
  161.             if (giMonth==iMonth) {
  162.                 if (giDay>=myMonth[w+1][d]) {
  163.                     color = ((d==0)||(d==6))?"#AA0000":"black";
  164.                     innerHTML  =myMonth[w+1][d];
  165.                 }
  166.                 else {
  167.                     color = gcGray;
  168.                     innerHTML  =myMonth[w+1][d];
  169.                 }
  170.             }
  171.             else {
  172.                 color = gcGray;
  173.                 innerHTML  =myMonth[w+1][d];
  174.             }
  175.         }
  176.     else
  177.         if (giYear==iYear) {
  178.                 if (giMonth<iMonth) {
  179.                     color = ((d==0)||(d==6))?"#AA0000":"black";
  180.                     innerHTML  =myMonth[w+1][d];
  181.                 }
  182.                 else {
  183.                     if (giMonth==iMonth) {
  184.                         if (giDay<=myMonth[w+1][d]) {
  185.                             color = ((d==0)||(d==6))?"#AA0000":"black";
  186.                             innerHTML  =myMonth[w+1][d];
  187.                         }
  188.                         else {
  189.                             color = gcGray;
  190.                             innerHTML =myMonth[w+1][d];
  191.                         }
  192.                     }
  193.                     else {
  194.                         color = gcGray;
  195.                         innerHTML =myMonth[w+1][d];
  196.                     }
  197.                 }
  198.         }
  199.         if(giYear==iYear && giMonth==iMonth && giDay==myMonth[w+1][d]) { //fecha de hoy
  200.             color = "#CC0000";
  201.         }
  202.         if(iYear==yearfechado && iMonth==mesfechado && myMonth[w+1][d]==diafechado) { //fecha seleccionada
  203.             color = "red";
  204.             bgColor="black";
  205.         }
  206.  
  207.             }
  208.         }
  209.    
  210. }
  211.  
  212. function fSetYearMon(iYear, iMon){
  213.   window.document.getElementById('tbSelMonth').options[iMon-1].selected = true;
  214.   //tbSelMonth.options[iMon-1].selected = true;
  215.  
  216.   for (i = 0; i < window.document.getElementById('tbSelYear').length; i++)
  217.  // for (i = 0; i < tbSelYear.length; i++)
  218.  
  219.   if (window.document.getElementById('tbSelYear').options[i].value == iYear)
  220. //  if (tbSelYear.options[i].value == iYear)
  221.         window.document.getElementById('tbSelYear').options[i].selected = true;
  222. //      tbSelYear.options[i].selected = true;
  223.   fUpdateCal(iYear, iMon);
  224. }
  225.  
  226.  
  227.  
  228. function fGetXY(aTag){
  229.   var oTmp = aTag;
  230.   var pt = new Point(0,0);
  231.   do {
  232.     pt.x += oTmp.offsetLeft;
  233.     pt.y += oTmp.offsetTop;
  234.     oTmp = oTmp.offsetParent;
  235.   } while(oTmp.tagName!="BODY");
  236.   return pt;
  237. }
  238.  
  239. var gMonths = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  240.  
  241. with (document) {
  242. //write("<p align=right > . </p>");
  243. write("<BODY leftMargin=0 topMargin=0 > <p>");
  244. write("<table id='popTable' border='0' >");
  245. write("<TR>");
  246. write("<td align='middle' align='center' >");
  247. write('&nbsp;<select name="tbSelMonth" id="tbSelMonth" onChange="fUpdateCal(window.document.getElementById('+"'tbSelYear'"+').value, window.document.getElementById('+"'tbSelMonth'"+').value)" class="fecha">');
  248. for (i=0; i<12; i++)
  249.         write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
  250. write("</SELECT>");
  251. write('&nbsp;<SELECT name="tbSelYear" id="tbSelYear" onChange="fUpdateCal(window.document.getElementById('+"'tbSelYear'"+').value, window.document.getElementById('+"'tbSelMonth'"+').value)" class="fecha">');
  252. for(i=giYear;i<=giYear+1;i++)
  253.     write("<OPTION value='"+i+"'>"+i+"</OPTION>");
  254. write("</SELECT> <font class='calendario' style='cursor:pointer; font-size: 14px; color:green;' onclick='cerrar()' onMouseOver='this.style.color=overCerrar' onMouseOut='this.style.color=gcdarkblue' valing='right'>| x |</font>");
  255.  
  256. write("</td>");
  257. write("</TR><TR>");
  258. write("<td align='center'>");
  259. write("<DIV'><table width='100%' border='0' cellpadding='0' style='cursor:pointer;'>");
  260. fDrawCal(giYear, giMonth, 19, 12);
  261. write("</table></DIV>");
  262. write("</td>");
  263. write("</TR><TR><TD align='center'>");
  264. write("<font style='cursor:pointer; font:bold 12 Verdana ; color:#CC0000;' onclick='fSetDate(giYear,giMonth,giDay)' onMouseOver='this.style.color=overCerrar' onMouseOut='this.style.color=gcdarkblue; '>Hoy :&nbsp;&nbsp;"+giDay+"&nbsp;"+gMonths[giMonth-1]+",&nbsp;"+giYear+"</font><br>");
  265. write("</TD></TR>");
  266. write("</TD></TR>");
  267. write("</TABLE>");
  268. }
  269.  
  270. </SCRIPT>

Y cual es el problema?
pues no puedo seleccionar las fechas anteriores al dia actual, supongo que debe ser alguna bobada que hay que modificar pero honestamente no eh dado con la solucion.