Ir para conteúdo
Fórum Script Brasil
  • 0

Calendário só funciona no Chrome


Rodrigo Kx

Pergunta

Galera, segue o código do calendário que só funciona no chrome,

java script:

<!-- Calendário -->

            // construindo o calendário
            function popdate(obj,div,tam,ddd)
            {
                if (ddd) 
                {
                    day = ""
                    mmonth = ""
                    ano = ""
                    c = 1
                    char = ""
                    for (s=0;s<parseInt(ddd.length);s++)
                    {
                        char = ddd.substr(s,1)
                        if (char == "-") 
                        {
                            c++; 
                            s++; 
                            char = ddd.substr(s,1);
                        }
                        if (c==1) day    += char
                        if (c==2) mmonth += char
                        if (c==3) ano    += char
                    }
                    ddd = ano + "-" + mmonth + "-" + day
                }
              
                if(!ddd) {today = new Date()} else {today = new Date(ddd)}
                date_Form = eval (obj)
                if (date_Form.value == "") { date_Form = new Date()} else {date_Form = new Date(date_Form.value)}
              
                ano = today.getFullYear();
                mmonth = today.getMonth ();
                day = today.toString ().substr (8,2)
              
                umonth = new Array ("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro")
                days_Feb = (!(ano % 4) ? 29 : 28)
                days = new Array (31, days_Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
            
                if ((mmonth < 0) || (mmonth > 11))  alert(mmonth)
                if ((mmonth - 1) == -1) {month_prior = 11; year_prior = ano - 1} else {month_prior = mmonth - 1; year_prior = ano}
                if ((mmonth + 1) == 12) {month_next  = 0;  year_next  = ano + 1} else {month_next  = mmonth + 1; year_next  = ano}
                txt  = "<table bgcolor='#FFFFFF' style='border:2px solid #c3c3c3; font-size:11px; border-width:'1' cellspacing='0' cellpadding='3' border='0' width='"+tam+"' height='"+tam*1.1 +"'>"
                txt += "<tr bgcolor='#FFFFFF'><td colspan='7' align='center'><table border='0' cellpadding='0' width='100%' bgcolor='#FFFFFF'><tr>"
                txt += "<td width=20% align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"-01-"+(ano-1).toString())+"') class='Cabecalho_Calendario' title='Ano Anterior'><<</a></td>"
                txt += "<td width=20% align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01-" + (month_prior+1).toString() + "-" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mês Anterior'><</a></td>"
                txt += "<td width=20% align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01-" + (month_next+1).toString()  + "-" + year_next.toString())+"') class='Cabecalho_Calendario' title='Próximo Mês'>></a></td>"
                txt += "<td width=20% align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"-01-"+(ano+1).toString())+"') class='Cabecalho_Calendario' title='Próximo Ano'>>></a></td>"
                txt += "<td width=20% align=right><a href=java script:force_close('"+div+"') class='Cabecalho_Calendario' title='Fechar Calendário'><b>x</b></a></td></tr></table></td></tr>"
                txt += "<tr><td colspan='7' align='right' bgcolor='#f6f6f6' class='mes'><a href=java script:pop_year('"+obj+"','"+div+"','"+tam+"','" + (mmonth+1) + "') class='mes'>" + ano.toString() + "</a>"
                txt += " <a href=java script:pop_month('"+obj+"','"+div+"','"+tam+"','" + ano + "') class='mes'>" + umonth[mmonth] + "</a> <div id='popd' style='position:absolute'></div></td></tr>"
                txt += "<tr bgcolor='silver'><td width='14%' class='dia' align=center style='font-color:black;'><b>Dom</b></td><td width='14%' class='dia' align=center><b>Seg</b></td><td width='14%' class='dia' align=center><b>Ter</b></td><td width='14%' class='dia' align=center><b>Qua</b></td><td width='14%' class='dia' align=center><b>Qui</b></td><td width='14%' class='dia' align=center><b>Sex<b></td><td width='14%' class='dia' align=center><b>Sab</b></td></tr>"
                today1 = new Date((mmonth+1).toString() +"-01-"+ano.toString());
                diainicio = today1.getDay () + 1;
                week = d = 1
                start = false;
            
                for (n=1;n<= 42;n++) 
                {
                    if (week == 1)  txt += "<tr bgcolor='#F6F6F6' align=center>"
                    if (week==diainicio) {start = true}
                    if (d > days[mmonth]) {start=false}
                    if (start) 
                    {
                        dat = new Date((mmonth+1).toString() + "-" + d + "-" + ano.toString())
                        day_dat   = dat.toString().substr(0,10)
                        day_today  = date_Form.toString().substr(0,10)
                        year_dat  = dat.getFullYear ()
                        year_today = date_Form.getFullYear ()
                        colorcell = ((day_dat == day_today) && (year_dat == year_today) ? " bgcolor='silver' " : "" )
                        
                        if (d < 10 && mmonth < 9)
                        txt += "<td"+colorcell+" align=center><a href=java script:block('0"+  d + "-0" + (mmonth+1).toString() + "-" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ d.toString() + "</a></td>"
                        else if (d < 10)
                        txt += "<td"+colorcell+" align=center><a href=java script:block('0"+  d + "-" + (mmonth+1).toString() + "-" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ d.toString() + "</a></td>"
                        else if(mmonth < 9)
                        txt += "<td"+colorcell+" align=center><a href=java script:block('"+  d + "-0" + (mmonth+1).toString() + "-" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ d.toString() + "</a></td>"
                        else
                        txt += "<td"+colorcell+" align=center><a href=java script:block('"+  d + "-" + (mmonth+1).toString() + "-" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ d.toString() + "</a></td>"        
                        
                    
                        d ++ 
                    } 
                    else 
                    { 
                        txt += "<td class='data' align=center> </td>"
                    }
                    week ++
                    if (week == 8) 
                    { 
                        week = 1; txt += "</tr>"} 
                    }
                    txt += "</table>"
                    ///////////////////////////////////
                    document.getElementById("pop1").innerHTML = txt
                    ///////////////////////////////////
            }
              
            // função para exibir a janela com os meses
            function pop_month(obj, div, tam, ano)
            {
              txt  = "<table bgcolor='#CCCCFF' border='0' width=80>"
              for (n = 0; n < 12; n++) { txt += "<tr><td align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+("01-" + (n+1).toString() + "-" + ano.toString())+"')>" + umonth[n] +"</a></td></tr>" }
              txt += "</table>"
              popd.innerHTML = txt
            }
            
            // função para exibir a janela com os anos
            function pop_year(obj, div, tam, umonth)
            {
              txt  = "<table bgcolor='#CCCCFF' border='0' width=160>"
              l = 1
              for (n=1991; n<2012; n++)
              {  if (l == 1) txt += "<tr>"
                 txt += "<td align=center><a href=java script:popdate('"+obj+"','"+div+"','"+tam+"','"+(umonth.toString () +"-01-" + n) +"')>" + n + "</a></td>"
                 l++
                 if (l == 4) 
                    {txt += "</tr>"; l = 1 } 
              }
              txt += "</tr></table>"
              popd.innerHTML = txt 
            }
            
            // função para fechar o calendário
            function force_close(div) 
                {
                document.getElementById("pop1").innerHTML = ''
                }
                
            // função para fechar o calendário e setar a data no campo de data associado
            function block(data, obj, div)
            { 
                force_close (div)
                obj2 = eval(obj)
                obj2.value = data 
            }
HTML:
<td align="right" height=27>Data Inicial:</td>
    
      <td valign=top align="left">
      
            <input name="data1" value="<?php echo date("d-m-Y"); ?>" size="11" maxlength="10" onKeyPress="MascaraData1(form1.data1);" maxlength="10" onBlur= "ValidaData1(form1.data1);"/>

            <img src="images/icone_calendario.png" onclick="java script:popdate('document.form1.data1','pop1','150',document.form1.data1.value)"/>
            <span id="pop1" style="position:absolute; margin-left:14px;"></span>
    
      
      </td>
      
  </tr>
    
  <tr>
    <td align="right">Data Final:</td>
    
      <td valign=top align="left">
      
             <input name="data2" value="<?php echo date("d-m-Y"); ?>" size="11" maxlength="10" onKeyPress="MascaraData2(form1.data2);" maxlength="10" onBlur= "ValidaData2(form1.data2);"/>
        
          <img src="images/icone_calendario.png" onclick="java script:popdate('document.form1.data2','pop2','150',document.form1.data2.value)" />
          <span id="pop2" style="position:absolute; "></span>

      
      </td>

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...