Visualizzazione dei risultati da 1 a 2 su 2

Discussione: calendario con link

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2006
    Messaggi
    3

    calendario con link

    CALENDARIO con LINK
    Ciao a tutti, mi serve un grosso aiuto, innanzi tutto, ho una script che mi genera un calendario perpetuo, ho bisogno di effettuare i link per ogni giorno dell'anno, però non ho un database che mi gestisce il tutto... come posso fare in modo da avere un link su ogni giorno dell'anno e ad ogni link avere l'effettivo giorno corrispondente... qui di sotto scrivo anche la script...


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Applicazione di Tavole Dinamiche in javaScript</TITLE>
    <SCRIPT TYPE="text/javascript">
    <!--
    // Funzione che ritorna il giorno della settimana (0=Dom, 6=Sab)
    // del primo giorno del mese (theMonth, theYear) passato come paramento.
    //
    function getFirstDay(theYear, theMonth){
    var firstDate = new Date(theYear,theMonth,1);
    return firstDate.getDay()
    }

    // Funzione che calcola il numero di giorni del mese (theMonth, theYear)
    // Note:
    // il metodo <data>.getTime ritorna i millisecondi trascorsi dall'1/1/1970;
    // il metodo Math.ceil(X) ritorna l'intero superione di X.
    function getMonthLen(theYear, theMonth) {
    var oneDay = 1000 * 60 * 60 * 24;
    var thisMonth = new Date(theYear, theMonth, 1);
    var nextMonth = new Date(theYear, theMonth + 1, 1);
    var len = Math.ceil((nextMonth.getTime() - thisMonth.getTime())/oneDay);
    return len
    }

    // Funzione che ritorna l'anno sempre su quattro cifre, correggendo
    // l'anomalia di JavaScript che esprime gli anni 1900-1999 con due.
    function getY2KYear(today) {
    var yr = today.getYear();
    return ((yr < 1900) ? yr+1900 : yr)
    }
    // Creazione dell'array dei mesi
    theMonths = new MakeArray(12);

    // Inizializzazione dell'array dei mesi
    function MakeArray(n) {
    this[0] = "Gennaio";
    this[1] = "Febbraio";
    this[2] = "Marzo";
    this[3] = "Aprile";
    this[4] = "Maggio";
    this[5] = "Giugno";
    this[6] = "Luglio";
    this[7] = "Augosto";
    this[8] = "Settembre";
    this[9] = "Ottobre";
    this[10] = "Novembre";
    this[11] = "Dicembre";
    this.length = n;
    return this
    }
    // Funzione che riempie le celle della Tabella-Calendario
    function populateFields(form) {

    // Acquisisce Mese (0-11) ed Anno ("1999"-"2007") indicati dall'utente
    var theMonth = form.chooseMonth.selectedIndex;
    var theYear = form.chooseYear.options[form.chooseYear.selectedIndex].text;
    // initialize date-dependent variables

    // Individua il giorno della settimana del primo giorno del mese
    var firstDay = getFirstDay(theYear, theMonth);

    // Individua gli elementi della tabella da riempire con i giorni del mese
    var howMany = getMonthLen(theYear, theMonth);

    // Intestazione della tabella
    form.oneMonth.value = theMonths[theMonth] + " " + theYear;

    // Riempimento della tabella
    for (var i = 0; i < 42; i++) {
    if (i < firstDay || i >= (howMany + firstDay)) {
    // inserisce "" nelle caselle vuote
    form.oneDay[i].value = ""
    } else {
    // Inserisce le date nelle caselle piene
    form.oneDay[i].value = i - firstDay + 1
    }
    }
    }

    -->
    </SCRIPT>
    </HEAD>

    <BODY>
    <H1 Align="Center">Calendario Dinamico</H1>
    <HR>
    <SCRIPT TYPE="text/javascript">
    <!--
    // definisce la tringa HTML per creare un singolo elemento di input
    // nella tabella
    var oneField = "<INPUT TYPE='text' NAME='oneDay' SIZE=3>";

    // Crea la tabella utilizzando la variabile JS content
    var content = "<FORM><CENTER><TABLE BORDER=1>";

    // Crea l'intestazione della tabella (mese,anno)
    content += "<TR><TH COLSPAN=7><INPUT TYPE='text' NAME='oneMonth'></TH></TR>";

    // Crea l'intestazione delle colonne con i giorni della settimana
    content += "<TR><TH>Dom</TH><TH>Lun</TH><TH>Mar</TH><TH>Mer</TH>";
    content += "<TH>Gio</TH><TH>Ven</TH><TH>Sab</TH></TR>";
    content += "<TR>";

    // Crea le celle per i giorni
    for (var i = 1; i < 43; i++) {
    content += "<TD ALIGN='middle'>" + oneField + "</TD>";
    if (i % 7 == 0) {
    content += "</TR><TR>"
    }
    }

    content += "</TABLE>";

    // Genera il codice HTML per la tabella vuota
    document.write(content);

    -->
    </SCRIPT>
    <form>
    <SELECT NAME="chooseMonth">
    <OPTION SELECTED>Gennaio <OPTION>Febbraio <OPTION>Marzo
    <OPTION>Aprile <OPTION>Maggio <OPTION>Giugno
    <OPTION>Luglio <OPTION>Agosto <OPTION>Settembre
    <OPTION>Ottobre <OPTION>Novembre <OPTION>Dicembre
    </SELECT>
    <SELECT NAME="chooseYear">
    <OPTION>1999 <OPTION>2000 <OPTION>2001 <OPTION>2002<OPTION>2003
    <OPTION SELECTED>2004 <OPTION>2005 <OPTION>2006 <OPTION>2007
    </SELECT>
    <INPUT TYPE="button" NAME="updater" VALUE="Aggiorna Calendario" onClick="populateFields(this.form)">
    </FORM>
    </BODY>
    </HTML>


    ovviamente ho già le pagine dei giorni che si trovano nelle cartelle
    /MESExx/giornoxx.html

    Mi serve un modo per linkare i giorni alle pagine, non lo so magari tramite qualche funzione che cerca tra le cartelle boh, essendo una script automatica i link che crea cambiano in base al mese, boh ci sto diventando matto...
    PS: non ho a disposizione un database per questo cerco aiuto...

    GRAZIE, spero mi saprete essere d'aiuto...!!!

  2. #2

    Re: calendario con link

    Originariamente inviato da ximomix
    CALENDARIO con LINK
    Ciao a tutti, mi serve un grosso aiuto, innanzi tutto, ho una script che mi genera un calendario perpetuo, ho bisogno di effettuare i link per ogni giorno dell'anno, però non ho un database che mi gestisce il tutto... come posso fare in modo da avere un link su ogni giorno dell'anno e ad ogni link avere l'effettivo giorno corrispondente... qui di sotto scrivo anche la script...


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Applicazione di Tavole Dinamiche in javaScript</TITLE>
    <SCRIPT TYPE="text/javascript">
    <!--
    // Funzione che ritorna il giorno della settimana (0=Dom, 6=Sab)
    // del primo giorno del mese (theMonth, theYear) passato come paramento.
    //
    function getFirstDay(theYear, theMonth){
    var firstDate = new Date(theYear,theMonth,1);
    return firstDate.getDay()
    }

    // Funzione che calcola il numero di giorni del mese (theMonth, theYear)
    // Note:
    // il metodo <data>.getTime ritorna i millisecondi trascorsi dall'1/1/1970;
    // il metodo Math.ceil(X) ritorna l'intero superione di X.
    function getMonthLen(theYear, theMonth) {
    var oneDay = 1000 * 60 * 60 * 24;
    var thisMonth = new Date(theYear, theMonth, 1);
    var nextMonth = new Date(theYear, theMonth + 1, 1);
    var len = Math.ceil((nextMonth.getTime() - thisMonth.getTime())/oneDay);
    return len
    }

    // Funzione che ritorna l'anno sempre su quattro cifre, correggendo
    // l'anomalia di JavaScript che esprime gli anni 1900-1999 con due.
    function getY2KYear(today) {
    var yr = today.getYear();
    return ((yr < 1900) ? yr+1900 : yr)
    }
    // Creazione dell'array dei mesi
    theMonths = new MakeArray(12);

    // Inizializzazione dell'array dei mesi
    function MakeArray(n) {
    this[0] = "Gennaio";
    this[1] = "Febbraio";
    this[2] = "Marzo";
    this[3] = "Aprile";
    this[4] = "Maggio";
    this[5] = "Giugno";
    this[6] = "Luglio";
    this[7] = "Augosto";
    this[8] = "Settembre";
    this[9] = "Ottobre";
    this[10] = "Novembre";
    this[11] = "Dicembre";
    this.length = n;
    return this
    }
    // Funzione che riempie le celle della Tabella-Calendario
    function populateFields(form) {

    // Acquisisce Mese (0-11) ed Anno ("1999"-"2007") indicati dall'utente
    var theMonth = form.chooseMonth.selectedIndex;
    var theYear = form.chooseYear.options[form.chooseYear.selectedIndex].text;
    // initialize date-dependent variables

    // Individua il giorno della settimana del primo giorno del mese
    var firstDay = getFirstDay(theYear, theMonth);

    // Individua gli elementi della tabella da riempire con i giorni del mese
    var howMany = getMonthLen(theYear, theMonth);

    // Intestazione della tabella
    form.oneMonth.value = theMonths[theMonth] + " " + theYear;

    // Riempimento della tabella
    for (var i = 0; i < 42; i++) {
    if (i < firstDay || i >= (howMany + firstDay)) {
    // inserisce "" nelle caselle vuote
    form.oneDay[i].value = ""
    } else {
    // Inserisce le date nelle caselle piene
    form.oneDay[i].value = i - firstDay + 1
    }
    }
    }

    -->
    </SCRIPT>
    </HEAD>

    <BODY>
    <H1 Align="Center">Calendario Dinamico</H1>
    <HR>
    <SCRIPT TYPE="text/javascript">
    <!--
    // definisce la tringa HTML per creare un singolo elemento di input
    // nella tabella
    var oneField = "<INPUT TYPE='text' NAME='oneDay' SIZE=3>";

    // Crea la tabella utilizzando la variabile JS content
    var content = "<FORM><CENTER><TABLE BORDER=1>";

    // Crea l'intestazione della tabella (mese,anno)
    content += "<TR><TH COLSPAN=7><INPUT TYPE='text' NAME='oneMonth'></TH></TR>";

    // Crea l'intestazione delle colonne con i giorni della settimana
    content += "<TR><TH>Dom</TH><TH>Lun</TH><TH>Mar</TH><TH>Mer</TH>";
    content += "<TH>Gio</TH><TH>Ven</TH><TH>Sab</TH></TR>";
    content += "<TR>";

    // Crea le celle per i giorni
    for (var i = 1; i < 43; i++) {
    content += "<TD ALIGN='middle'>" + oneField + "</TD>";
    if (i % 7 == 0) {
    content += "</TR><TR>"
    }
    }

    content += "</TABLE>";

    // Genera il codice HTML per la tabella vuota
    document.write(content);

    -->
    </SCRIPT>
    <form>
    <SELECT NAME="chooseMonth">
    <OPTION SELECTED>Gennaio <OPTION>Febbraio <OPTION>Marzo
    <OPTION>Aprile <OPTION>Maggio <OPTION>Giugno
    <OPTION>Luglio <OPTION>Agosto <OPTION>Settembre
    <OPTION>Ottobre <OPTION>Novembre <OPTION>Dicembre
    </SELECT>
    <SELECT NAME="chooseYear">
    <OPTION>1999 <OPTION>2000 <OPTION>2001 <OPTION>2002<OPTION>2003
    <OPTION SELECTED>2004 <OPTION>2005 <OPTION>2006 <OPTION>2007
    </SELECT>
    <INPUT TYPE="button" NAME="updater" VALUE="Aggiorna Calendario" onClick="populateFields(this.form)">
    </FORM>
    </BODY>
    </HTML>


    ovviamente ho già le pagine dei giorni che si trovano nelle cartelle
    /MESExx/giornoxx.html

    Mi serve un modo per linkare i giorni alle pagine, non lo so magari tramite qualche funzione che cerca tra le cartelle boh, essendo una script automatica i link che crea cambiano in base al mese, boh ci sto diventando matto...
    PS: non ho a disposizione un database per questo cerco aiuto...

    GRAZIE, spero mi saprete essere d'aiuto...!!!
    problema diverso ma serve pure a me
    :quote:IL MIO NOME è MAI PIU:quote:

    No alla pena di morte

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.