Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 38
  1. #1

    Calendario php. Sarebbe da inserire nelle pillole

    Questo è un calendario in php completo. Sarebbe da inserire nelle pillole visto che è più unico che raro. Serve per inserire in un campo la data tramite un banalissimo pulsantino o link che apre un pop.

    L'unica cosa che non riesco a modificare è il giorno nel formato gg. Ho guardato ovunque e non riesco a risolvere il problema penso risieda in queste due funzioni.
    $first_day = mktime(0,0,0,$mon,1,$year);
    $start_day = date("w",$first_day);
    Non riesco a metterle con la doppia.
    Se qualcuno vuole darme un'occhiata. la data viene inserita nel formato g/mm/aaaa. Sarebbe utile inserirla in gg/mm/aaaa.
    Ringrazio 13manuel84 che mi ha passato quasi tutto il codice. Poi l'ho sistemato un pochino.

    codice:
    <script language="Javascript"> 
    function Selezionato(w_data) 
    { 
    window.opener.document.form1.data.value = w_data; 
    setTimeout('window.close()',100); 
    } 
    </script>
    Codice PHP:
    function print_HTML_header()
    {
        global 
    $flag;
        
    /*    echo "Mese: ".$_GET['month'];    
        echo "
    Anno: ".$_GET['year'];    */
        
    $flag = (isset($_GET['month']) && ($_GET['month'] <> date("m") || $_GET['year'] <> date("Y"))) ? 0;
        
        echo     
    "<HTML>\n<HEAD>\n<STYLE>\n".
                 
    "\n</STYLE>".
                 
    "<TITLE>Calendario\n</TITLE>\n</HEAD>\n<BODY BACKGROUND='images/bg.gif'>\n\n".
                 
    "<P ALIGN='center' CLASS='content'>Seleziona la data in cui pubblicare la news:</P>";
    }
        

    //----------------- Funzione per la chiusura dei tag HTML -----------------//

    function  print_HTML_footer()
    {
        echo 
    "</BODY></HTML>";
    }

    //----------------- Funzione che stampa il calendario -----------------//

    function  print_calendar($mon,$year)
        {
            global 
    $dates$first_day$start_day$flag;
            
            
    $first_day mktime(0,0,0,$mon,1,$year);
            
    $start_day date("w",$first_day);
            
    $res getdate($first_day);
            
    $month_name $res["month"];
            
    $no_days_in_month date("t"$first_day);    // t -> numero dei giorno del mese
            
            //Controllo se il primo giorno del mese è una Domenica altrimenti riempio di spazi fino ad arrivare al primo giorno
            
    for ($i 1$i <= $start_day;$i++)
                
    $dates[1][$i] = " ";

            
    $row 1;
            
    $col $start_day 1;
            
    $num 1;    //contatore dei giorni del mese
            
    while($num <= 31){
                if (
    $num $no_days_in_month)    break;    //se non ci sono più giorni nel mese esco da ciclo
                
    else{
                    
    $dates[$row][$col] = $num;
                    if ((
    $col 1) > 7){    //se sono arrivato alla fine della settimana devo scendere di una riga
                        
    $row += 1;
                        
    $col 1;
                    }else
                        
    $col += 1;
                    
    $num += 1
                }
    //fine if-else
            
    }//fine while

            
    $mon_num date("m",$first_day);    //calcolo del numero del mese -> n = senza eventuali 0
            
    $temp_yr $next_yr $prev_yr $year;    //imposto l'anno di visualizzazione

            
    $prev $mon_num 1;
            
    $next $mon_num 1;

            
    //Se Gennaio è il mese corrente imposto il mese precedente a Dicembre dell'anno precedente
            
    if ($mon_num == 1){
                
    $prev_yr $year 1;
                
    $prev 12;
            }
        
            
    //Se il dicembre è il mese corrente imposto il mese successivo a Gennaio dell'anno successivo
            
    if ($mon_num == 12){
                
    $next_yr $year 1;
                
    $next 1;
            }

            echo 
    "<DIV ALIGN='center'><TABLE BORDER=0 WIDTH=350 CELLSPACING=0";


            
    //trasformo i mesi dal formato standard a quello italiano        
            
    if (date("F"$first_day) == 'January')            {    $mese 'Gennaio';        $n '01';    }
            elseif (
    date("F"$first_day) == 'February')    {    $mese 'Febbraio';        $n '02';    }
            elseif (
    date("F"$first_day) == 'March')        {    $mese 'Marzo';        $n '03';    }
            elseif (
    date("F"$first_day) == 'April')        {    $mese 'Aprile';        $n '04';    }
            elseif (
    date("F"$first_day) == 'May')            {    $mese 'Maggio';        $n '05';    }
            elseif (
    date("F"$first_day) == 'June')        {    $mese 'Giugno';        $n '06';    }
            elseif (
    date("F"$first_day) == 'July')        {    $mese 'Luglio';        $n '07';    }
            elseif (
    date("F"$first_day) == 'August')        {    $mese 'Agosto';        $n '08';    }
            elseif (
    date("F"$first_day) == 'September')    {    $mese 'Settembre';    $n '09';    }
            elseif (
    date("F"$first_day) == 'October')        {    $mese 'Ottobre';        $n '10';    }
            elseif (
    date("F"$first_day) == 'November')    {    $mese 'Novembre';        $n '11';    }
            elseif (
    date("F"$first_day) == 'December')    {    $mese 'Dicembre';        $n '12';    }

            
    //imposto le variabili per navigare negli anni
            
    $anno_dopo $year 1;
            
    $anno_prima $year 1;
            
            
    //ricevo da GET la variabile contenente il mese in visualizzazione
            
    $month $_GET['month'];
            if (
    $month == ''){    $month date("m");    }
            
            echo     
    "\n<TR ALIGN='center'><TD BGCOLOR='#4682B4' ALIGN='left' CLASS='titoli'> ".
                 
    "[url='phpcalendar.php?month=$prev&year=$prev_yr']<img src=\"images/prev_month.gif\" border=0 title=\"Mese precedente\">[/url] </TD>".
                 
    "<TD COLSPAN=5 BGCOLOR='#4682B4' ALIGN='center' CLASS='corrente'>[B]".$mese." ".$temp_yr."[/B]</TD>".
                 
    "<TD BGCOLOR='#4682B4' ALIGN='right' CLASS='titoli'> ".
                 
    "[url='phpcalendar.php?month=$next&year=$next_yr']<img src=\"images/next_month.gif\" border=0 title=\"Mese Successivo\"> [/url] </TD></TR>";

            echo 
    "\n<TR ALIGN='center' CLASS='content'><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Dom[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Lun[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Mar[/B]</TD>";
            echo 
    "<TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Mer[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Gio[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Ven[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Sab[/B]</TD></TR>";
            echo 
    "<TR><TD COLSPAN=7> </TR><TR ALIGN='center'>";
                    
            
    $end = ($start_day 4)? 6:5;
            
    //ciclo che mi scrive i giorni!!
            
    for ($row 01$row <= $end$row++){
                for (
    $col 01$col <= 07$col++){
                    if (
    $dates[$row][$col] == '')    $dates[$row][$col] = ' ';
                            
                    if (!
    strcmp($dates[$row][$col], ' '))    $count += 1;
                            
                    
    $t $dates[$row][$col];    
                    
    $var $t.'/'.$mon.'/'.$year
                            
                    
    //Controllo se la data è oggi la evidenzio
                    
    if (($t == date("d")) && ($mon == date("m")) && ($year == date("Y"))){
                        echo 
    "\n<TD CLASS='corrente' BGCOLOR=\"#4682B4\">";
                        
    //echo "<a href=\"java script:Selezionato('$var')\" TITLE=\"$var\">";
                        
    echo "<a href=\"#\" onclick=\"Selezionato('$var');return false;\" TITLE=\"$var\">";
                        echo 
    $t."</a></TD>";
                    }else{    
    //Se il giorno non c'è metto uno spazio
                                
    echo "\n<TD  CLASS='titoli' BGCOLOR=\"#87CEFA\">".(($t == " " )? " " :"<a href=\"#\" onclick=\"Selezionato('$var');return false;\" TITLE=\"$var\">".$t)."</a> 
    "
    ;
                            }
                        }
    //fine for -colonne
                    
                    
    if (($row 1) != ($end+1))
                        echo 
    "</TR>\n<TR ALIGN='center'>";
                    else
                        echo 
    "</TR>";
                }
    //fine for - righe
                        
    echo "<TR><TD ALIGN=\"left\" BGCOLOR=\"#4682B4\"><a href=\"phpcalendar.php?month=$month&year=$anno_prima\" title=\"Anno precedente\"><img src=\"images/prev_year.gif\" border=0 title=\"Anno precedente\"></a></TD><TD COLSPAN=5 BGCOLOR=\"#4682B4\"> </TD><TD ALIGN=\"right\" BGCOLOR=\"#4682B4\"><a href=\"phpcalendar.php?month=$month&year=$anno_dopo\" title=\"Anno Successivo\"><img src=\"images/next_year.gif\" border=0 title=\"Anno successivo\"></a></TD></TR>";
            
            echo 
    "\n</TABLE>

    "
    ;
            
    /*    echo $flag. ' - ';    */
            
    if ($flag == '1')    echo "<A HREF=\"phpcalendar.php\" CLASS=\"content\">Visualizza il mese corrente</A></DIV>";
            

        }
        
    //----------Main Loop-----------


    //Se il mese non è presente lo setto a quello corrente
    $month = (empty($month)) ? date("m") : $month;

    //Se l'anno non è presente lo setto a quello corrente
    $year = (empty($year)) ? date("Y") : $year;

    print_HTML_header();

    print_calendar($month,$year);

    print_HTML_footer();

    ?> 

  2. #2

    Ho completanto lo script

    Ho completato lo scipt con il passaggio del dato campo via $_GET e con la possibilità di usare due date. aaaa/mm/gg e gg/mm/aaaa.
    Volevo allegare il file ma non posso perchè non accetta ne txt ne php. quindi metto tutto il codice.

    Esempio del passaggio del dato campo via $_GET. e dell'apertura del calendario in pop

    codice:
    <form name="form1" method="post" action="">
      
    
     
        <input name="campo1" type="text" id="campo1">
        <input name="Submit2" type="button" onClick="MM_openBrWindow('calendario.php?campo=campo1','','width=400,height=400')" value="calendario">
      </p>
      
    
     
        <input name="campo2" type="text" id="campo2">
        <input name="Submit22" type="button" onClick="MM_openBrWindow('calendario.php?campo=campo2','','width=400,height=400')" value="calendario">
      </p>
      
    
    
        <input type="submit" name="Submit" value="Invia">
      </p>
    </form>
    File calendario.php

    Codice PHP:
    <link href="up.css" rel="stylesheet" type="text/css">
    <?
    echo "<script language=\"Javascript\"> 
    function Selezionato(w_data) 

    window.opener.document.form1." 
    $_GET['campo'] . ".value = w_data; 
    setTimeout('window.close()',100); 

    </script> "
    ;

    //Variabile per visualizza mese corrente



    //----------------- This function is to do the HTML header chore ---------------------

    function print_HTML_header()
    {
        global 
    $flag;
        
    /*    echo "Mese: ".$_GET['month'];    
        echo "
    Anno: ".$_GET['year'];    */
        
    $flag = (isset($_GET['month']) && ($_GET['month'] <> date("m") || $_GET['year'] <> date("Y"))) ? 0;
        
        echo     
    "<HTML>\n<HEAD>\n<STYLE>\n".
                 
    "\n</STYLE>".
                 
    "<TITLE>Calendario\n</TITLE>\n</HEAD>\n<BODY BACKGROUND='images/bg.gif'>\n\n".
                 
    "<P ALIGN='center' CLASS='content'>Seleziona la data in cui pubblicare la news:</P>";
    }
        

    //----------------- Funzione per la chiusura dei tag HTML -----------------//

    function  print_HTML_footer()
    {
        echo 
    "</BODY></HTML>";
    }

    //----------------- Funzione che stampa il calendario -----------------//

    function  print_calendar($mon,$year)
        {
            global 
    $dates$first_day$start_day$flag;
            
            
    $first_day mktime(0,0,0,$mon,1,$year);
            
    $start_day date("w",$first_day);
            
    $res getdate($first_day);
            
    $month_name $res["month"];
            
    $no_days_in_month date("t"$first_day);    // t -> numero dei giorno del mese
            
            //Controllo se il primo giorno del mese è una Domenica altrimenti riempio di spazi fino ad arrivare al primo giorno
            
    for ($i 01$i <= $start_day;$i++)
                
    $dates[01][$i] = " ";

            
    $row 01;
            
    $col $start_day 1;
            
    $num 01;    //contatore dei giorni del mese
            
    while($num <= 31){
                if (
    $num $no_days_in_month)    break;    //se non ci sono più giorni nel mese esco da ciclo
                
    else{
                    
    $dates[$row][$col] = $num;
                    if ((
    $col 1) > 7){    //se sono arrivato alla fine della settimana devo scendere di una riga
                        
    $row += 1;
                        
    $col 1;
                    }else
                        
    $col += 1;
                    
    $num += 1
                }
    //fine if-else
            
    }//fine while

            
    $mon_num date("n",$first_day);    //calcolo del numero del mese -> n = senza eventuali 0
            
    $temp_yr $next_yr $prev_yr $year;    //imposto l'anno di visualizzazione

            
    $prev $mon_num 1;
            
    $next $mon_num 1;

            
    //Se Gennaio è il mese corrente imposto il mese precedente a Dicembre dell'anno precedente
            
    if ($mon_num == 1){
                
    $prev_yr $year 1;
                
    $prev 12;
            }
        
            
    //Se il dicembre è il mese corrente imposto il mese successivo a Gennaio dell'anno successivo
            
    if ($mon_num == 12){
                
    $next_yr $year 1;
                
    $next 1;
            }

            echo 
    "<DIV ALIGN='center'><TABLE BORDER=0 WIDTH=350 CELLSPACING=0";


            
    //trasformo i mesi dal formato standard a quello italiano        
            
    if (date("F"$first_day) == 'January')            {    $mese 'Gennaio';        $n '01';    }
            elseif (
    date("F"$first_day) == 'February')    {    $mese 'Febbraio';        $n '02';    }
            elseif (
    date("F"$first_day) == 'March')        {    $mese 'Marzo';        $n '03';    }
            elseif (
    date("F"$first_day) == 'April')        {    $mese 'Aprile';        $n '04';    }
            elseif (
    date("F"$first_day) == 'May')            {    $mese 'Maggio';        $n '05';    }
            elseif (
    date("F"$first_day) == 'June')        {    $mese 'Giugno';        $n '06';    }
            elseif (
    date("F"$first_day) == 'July')        {    $mese 'Luglio';        $n '07';    }
            elseif (
    date("F"$first_day) == 'August')        {    $mese 'Agosto';        $n '08';    }
            elseif (
    date("F"$first_day) == 'September')    {    $mese 'Settembre';    $n '09';    }
            elseif (
    date("F"$first_day) == 'October')        {    $mese 'Ottobre';        $n '10';    }
            elseif (
    date("F"$first_day) == 'November')    {    $mese 'Novembre';        $n '11';    }
            elseif (
    date("F"$first_day) == 'December')    {    $mese 'Dicembre';        $n '12';    }

            
    //imposto le variabili per navigare negli anni
            
    $anno_dopo $year 1;
            
    $anno_prima $year 1;
            
            
    //ricevo da GET la variabile contenente il mese in visualizzazione
            
    $month $_GET['month'];
            if (
    $month == ''){    $month date("m");    }
            
            echo     
    "\n<TR ALIGN='center'><TD BGCOLOR='#4682B4' ALIGN='left' CLASS='titoli'> ".
                 
    "[url='calendario.php?month=$prev&year=$prev_yr&campo="$_GET[']<img src=\"images/prev_month.gif\" border=0 title=\"Mese precedente\">[/url] </TD>".
                 "<TD COLSPAN=5 BGCOLOR='
    #4682B4' ALIGN='center' CLASS='corrente'>[B]".$mese." ".$temp_yr."[/B]</TD>".
                 
    "<TD BGCOLOR='#4682B4' ALIGN='right' CLASS='titoli'> ".
                 
    "[url='calendario.php?month=$next&year=$next_yr&campo="$_GET[']<img src=\"images/next_month.gif\" border=0 title=\"Mese Successivo\"> [/url] </TD></TR>";

            echo "\n<TR ALIGN='
    center' CLASS='content'><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Dom[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Lun[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Mar[/B]</TD>";
            echo "<TD CLASS='
    content' BGCOLOR=\"#87CEFA\">[B]Mer[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Gio[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Ven[/B]</TD><TD CLASS='content' BGCOLOR=\"#87CEFA\">[B]Sab[/B]</TD></TR>";
            echo "<TR><TD COLSPAN=7> </TR><TR ALIGN='
    center'>";
                    
            $end = ($start_day > 4)? 6:5;
            //ciclo che mi scrive i giorni!!
            for ($row = 01; $row <= $end; $row++){
                for ($col = 01; $col <= 07; $col++){
                    if ($dates[$row][$col] == '')    $dates[$row][$col] = ' ';
                            
                    if (!strcmp($dates[$row][$col], ' '))    $count += 1;
                            
                    $t1 = $dates[$row][$col];
                    if ($t1==""){ 
                    $t = ""; 
                                }elseif ($t1>0 and $t1<10){
                                $t = "0" . $t1;
                                }else{
                                $t = $t1;
                                }
                                



                         
                    //Visualizzazione gg/mm/aaaa
                    //$var = $t.'
    /'.$mon.'/'.$year; 
                     
                     
                    //visualizzazione aaaa/mm/gg
                    $var = $year . "/" . $mon . "/" . $t;
                    
                    



                            
                    //Controllo se la data è oggi la evidenzio
                    if (($t == date("d")) && ($mon == date("m")) && ($year == date("Y"))){
                        echo "\n<TD CLASS='
    corrente' BGCOLOR=\"#4682B4\">";
                        //echo "<a href=\"java script:Selezionato('
    $var')\" TITLE=\"$var\">";
                        echo "<a href=\"#\" onclick=\"Selezionato('
    $var');return false;\" TITLE=\"$var\">";
                        echo $t."</a></TD>";
                    }else{    //Se il giorno non c'
    è metto uno spazio
                                
    echo "\n<TD  CLASS='titoli' BGCOLOR=\"#87CEFA\">".(($t == " " )? " " :"<a href=\"#\" onclick=\"Selezionato('$var');return false;\" TITLE=\"$var\">".$t)."</a> 
    "
    ;
                            }
                        }
    //fine for -colonne
                    
                    
    if (($row 1) != ($end+1))
                        echo 
    "</TR>\n<TR ALIGN='center'>";
                    else
                        echo 
    "</TR>";
                }
    //fine for - righe
                        
    echo "<TR><TD ALIGN=\"left\" BGCOLOR=\"#4682B4\"><a href=\"calendario.php?month=$month&year=$anno_prima&campo="$_GET['campo'] ."\" title=\"Anno precedente\"><img src=\"images/prev_year.gif\" border=0 title=\"Anno precedente\"></a></TD><TD COLSPAN=5 BGCOLOR=\"#4682B4\"> </TD><TD ALIGN=\"right\" BGCOLOR=\"#4682B4\"><a href=\"calendario.php?month=$month&year=$anno_dopo&campo="$_GET['campo'] ."\" title=\"Anno Successivo\"><img src=\"images/next_year.gif\" border=0 title=\"Anno successivo\"></a></TD></TR>";
            
            echo 
    "\n</TABLE>

    "
    ;
            
    /*    echo $flag. ' - ';    */
            
    if ($flag == '1'){
                echo 
    "<A HREF=\"calendario.php?campo=" $_GET['campo'] . "\" CLASS=\"content\">Visualizza il mese corrente</A></DIV>";
            }                
            

        }
        
    //----------Main Loop-----------


    //Se il mese non è presente lo setto a quello corrente
    $month = (empty($month)) ? date("m") : $month;

    //Se l'anno non è presente lo setto a quello corrente
    $year = (empty($year)) ? date("Y") : $year;

    print_HTML_header();

    print_calendar($month,$year);

    print_HTML_footer();




    ?>

    ciao ciao

  3. #3
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    La stessa cosa ma in javascript....

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>Calendario</title>
    </head>
    <body>
    <style type="text/css">
    <!--
    .monthHeader {font-family:verdana;font-size:8pt;background-color:darkblue;color:white;font-weight:bold}
    .calDay      {width:35px;font-family:verdana;font-size:8pt;color:darkblue;background-color:white;}
    .calHeader   {width:35px;font-family:verdana;font-size:8pt;background-color:darkblue;color:white}
    .calBtn      {width:30px;font-family:verdana;font-size:8pt}
    .weekEnd     {width:35px;font-family:verdana;font-size:8pt;color:darkblue;background-color:yellow;}
    .noDay       {width:35px;font-family:verdana;font-size:8pt;background-color:gray;}
    .curDay      {width:35px;font-family:verdana;font-size:8pt;background-color:red;color:white}
    -->
    </style>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    var dayNames = new Array('Dom','Lun','Mar','Mer','Gio','Ven','Sab');
    var mese     = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre');
    
    var previousYear  = 0;
    var previousMonth = 0;
    var nextYear      = 0;
    var nextMonth     = 0;
    var currentYear   = 0;
    var currentMonth  = 0;
    
    
    function sendDate(aDate) {
     //------------------ Inserire qui il codice per tramettere la data
     alert(aDate);
    } // function sendDate(aDate)
    
    function drawCal(aTable) {
     m = 0;
     for (l=0;l<=5;l++) {
      newRow = aTable.insertRow();
    	for (i=0;i<=6;i++) {
    	 newCell             = newRow.insertCell();
    	 newCell.className   = "calDay";
    	 newCell.innerHTML   = "&nbsp";	 
       newCell.align       = "center";	 	 
    	 newCell.id          = "day["+m+"]";
    	 newCell.vAlign      = "top"
    	 m++;
    	} // for (i=0;i<6;i++)
     } // for (l=0;l<=5;l++)
    } // function newWeek(aTable)
    
    //==============================================================================
    // Creazione della testata del calendario
    //==============================================================================
    function calHeader(aTable) {
      //----------- Riga per il mese
      newRow              = aTable.insertRow();
    	newCell             = newRow.insertCell();
    	newCell.colSpan     = 7;
    	newCell.align       = "center";
    	newCell.className   = "monthHeader";
    	newCell.id          = "monthHeader";	
    	newCell.innerHTML   = ""
    	//----------- Riga per i giorni
      newRow      = aTable.insertRow();
    	for (i=0;i<=6;i++) {
    	 newCell             = newRow.insertCell();
    	 newCell.className   = "calHeader";
    	 newCell.innerHTML   = dayNames[i];
       newCell.align       = "center";	 
    	 newCell.vAlign      = "top"
    	} // for (i=0;i<6;i++)
    } // function calHeader(aTable)
    
    function format2(aValue) {
     aString = new String(aValue);
     if (aString.length == 1) {
      return '0' + aString;
     } // if (aString.length == 1)
     return aString;
    } // function format2(aValue)
    
    
    //==============================================================================
    // Riempimento dei giorni nel calendario
    //==============================================================================
    function populateCal(aYear,aMonth) {
     var a = new Date();
     //------------ Today's day number
     today = a.getDate();
     //------------ Settaggio dell'anno
     a.setYear(aYear);
     //------------ Settaggio del mese
     a.setMonth(aMonth-1);
     //------------ calcolo dei 
     previousYear  = a.getFullYear()  - 1;
     previousMonth = a.getMonth() - 1;
     nextYear      = a.getFullYear()  + 1;
     nextMonth     = a.getMonth() + 1;  
     currentYear   = a.getFullYear();
     currentMonth  = a.getMonth(); 
     //------------ Settaggio del nome del Mese
     document.getElementById('monthHeader').innerHTML = mese[currentMonth] + " " + a.getFullYear(); 
     //------------ Primo giorno del mese per l'anno
     currentDay = 1;
     a.setDate(currentDay);
     //------------ N° del primo giorno nella settimana
     startDay  = a.getDay();
     //------------ Le prime celle non fanno parte del mese
     for (i=0;i<startDay;i++) {
      dayID     = "day["+i+"]";
      document.getElementById(dayID).className ='noDay' ;	 
     } // for (i=0;i<=startDay;i++)
     //------------ Settaggio primo giorno nella tabella
     dayID     = "day["+startDay+"]";
     funcParm  = "sendDate('"+aYear+'-'+format2(aMonth)+'-'+format2(currentDay)+"')";
     document.getElementById(dayID).innerHTML =''+currentDay+'' ;	
     //------------ Settaggio per gli altri giorni nella tabella
     cont     = true;
     while (cont) {
      currentDay++;
      a.setDate(currentDay);	
    	if (a.getMonth() == currentMonth+1 || a.getFullYear() != currentYear) {
    	 cont = false;
    	} else {
    	 calc      = startDay + currentDay - 1;
       dayID     = "day["+calc+"]";
       funcParm  = "sendDate('"+aYear+'-'+format2(aMonth)+'-'+format2(currentDay)+"')";
       document.getElementById(dayID).innerHTML =''+currentDay+'' ;	
    	 if (currentDay == today) {
    	  document.getElementById(dayID).className = 'curDay'; 
    	 } // if (currentDay == a.getDate())
    	} // if (a.getMonth() == aMonth)
     } // while (cont) 
     //------------ Le ultime celle non fanno parte del mese
     for (n=currentDay+startDay-1;n<=41;n++) {
      dayID  = "day["+n+"]";
      document.getElementById(dayID).className ='noDay' ;	 
     } // for (i=0;i<=startDay;i++) 
    } // function populateCal(aYear,aMonth)
    
    //==============================================================================
    // Piede del calendario dove ci sono i pulsanti
    //==============================================================================
    function calBottom(aTable) {
     //----------- Riga per i bottoni
     newRow      = aTable.insertRow();
     //----------- Bottone un anno indietro
     newCell             = newRow.insertCell();
     newCell.className   = "calBtn";
     newCell.innerHTML   = '<input type=button class=calBtn value="<<" onclick="changeCal(previousYear,currentMonth+1)">';
     newCell.align       = "center";	 
     newCell.vAlign      = "top"; 
     //----------- Bottone un mese indietro
     newCell             = newRow.insertCell();
     newCell.className   = "calBtn";
     newCell.innerHTML   = '<input type=button class=calBtn value="<" onclick="changeCal(currentYear,previousMonth+1)">';
     newCell.align       = "center";	 
     newCell.vAlign      = "top"; 
     //----------- Colspan di tre celle 
     newCell             = newRow.insertCell();
     newCell.colSpan     = 3;
     newCell.align       = "center";
     newCell.innerHTML   = ""; 
     //----------- Bottone un mese in avanti
     newCell             = newRow.insertCell();
     newCell.className   = "calBtn";
     newCell.innerHTML   = '<input type=button class=calBtn value=">" onclick="changeCal(currentYear,nextMonth+1)">';
     newCell.align       = "center";	 
     newCell.vAlign      = "top";  
     //----------- Bottone un anno in avanti
     newCell             = newRow.insertCell();
     newCell.className   = "calBtn";
     newCell.innerHTML   = '<input type=button class=calBtn value=">>" onclick="changeCal(nextYear,currentMonth+1)">';
     newCell.align       = "center";	 
     newCell.vAlign      = "top"; 
    } // function calBottom(aTable)
    
    //==============================================================================
    // Inizializzazione delle celle del calendario
    //==============================================================================
    function initCalendar(aTable) {
     //------------ Parte dalla 3° riga e si ferma alla penultima
     for (i=2;i<aTable.rows.length-1;i++) {
    	curRow = aTable.rows(i);
    	for (j=0;j<curRow.cells.length;j++) {
    	 curCell = curRow.cells(j);
    	 curCell.innerHTML = "";
    	 curCell.className = "calDay";	 
    	} // for (j=0;j<curRow.cells.length;j++)
     } // for (i=0;i<aTable.rows.length;i++)
    } // function initCalendar(aTable)
    
    //==============================================================================
    // Creazione del calendario
    //==============================================================================
    function createCalendar(aTable,aYear,aMonth) {
     if (aTable == null) {
      aTable = document.getElementById('calendar');
     } // if (aTable == null)
     //------------ Inizializzazione calendario
     initCalendar(aTable);
     //------------ Testata del calendario
     calHeader(aTable);
     //------------ Giorni del calendario
     drawCal(aTable);
     //------------ Assegnazione dei giorni
     populateCal(aYear,aMonth);
     //------------ Bottoni
     calBottom(aTable);
    } // function createCalendar(aTable,aYear,aMonth)
    
    //==============================================================================
    // Cambio mese o anno
    //==============================================================================
    function changeCal(aYear,aMonth) {
     //------------ Init calendario
     initCalendar(document.getElementById('calendar'));
     populateCal(aYear,aMonth);
    } // function changeCal(aYear,aMonth)
    //-->
    </script>
    
    <table id="calendar" border="1" style="border-color:yellow;background-color:#ffffcc"></table>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    curDate = new Date();
    //------------ Creazione del calendario
    createCalendar(calendar, curDate.getFullYear(),curDate.getMonth()+1);
    //-->
    </script>
    
    </body>
    </html>

  4. #4
    le pillole sono delle spiegazioni sugli argomenti non il semplice post di codice :stordite:

    fare una pillola vuol dire trattare un'argomento inerente a php...che può anche essere come costruire un calendario...seguendo i vari passi partendo da una cosa base e pian piano estendendola...ma sempre tramite spiegazioni ^^
    qui c'è solo codice

  5. #5
    @badaze

    Il tuo script funziona su Iexplorer, ma non su Firefox...
    codice:
    Errore: calendar is not defined
    Riga: 231
    
    createCalendar(calendar, curDate.getFullYear(), curDate.getMonth()+1);

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  6. #6
    Utente bannato
    Registrato dal
    Apr 2004
    Messaggi
    1,392
    Originariamente inviato da daniele_dll
    le pillole sono delle spiegazioni sugli argomenti non il semplice post di codice :stordite:

    fare una pillola vuol dire trattare un'argomento inerente a php...che può anche essere come costruire un calendario...seguendo i vari passi partendo da una cosa base e pian piano estendendola...ma sempre tramite spiegazioni ^^
    qui c'è solo codice

    Io ne so qualcosa...

  7. #7
    si avete perfettamente ragione....allora inserirlo negli script utili o cose del genere. sia quello in java che in php...più che altro non se ne trovano proprio in php e in java ha alcuni problemi con alcuni browser. In asp invece ce ne sono tonnellate.
    bha.
    Alla fine forse basta lasciarlo qui. nel titolo c'è la parola calendario php e quindi si dovrebbe trovare facilmente.
    ciao ciao

  8. #8
    Originariamente inviato da PaTeR

    Io ne so qualcosa...


    x massimo80

    Su www.freephp.it c'è una sezione apposita per gli scritp inseriti dagli italiani, basta registrarsi e mandare lo script

  9. #9
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Originariamente inviato da piero.mac
    @badaze

    Il tuo script funziona su Iexplorer, ma non su Firefox...
    codice:
    Errore: calendar is not defined
    Riga: 231
    
    createCalendar(calendar, curDate.getFullYear(), curDate.getMonth()+1);
    Non ho firefox !!!

    E con

    createCalendar(document.getElementById('calendar') , curDate.getFullYear(), curDate.getMonth()+1);

    ????

  10. #10
    Originariamente inviato da badaze
    Non ho firefox !!!

    E con

    createCalendar(document.getElementById('calendar') , curDate.getFullYear(), curDate.getMonth()+1);

    ????
    peggiora....

    Errore: uncaught exception: [Exception... "Not enough arguments [nsIDOMHTMLTableElement.insertRow]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://localhost/date/Calend_badaze.html :: calHeader :: line 58" data: no]

    Con IExplorer invece continua ad andare.

    Mi piacerebbe poterlo usare perche' e' carino ed ho il sito in boundle con la linea ADSL che non ha php.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.