Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13
  1. #1

    Formato input dell'oggetto Date()

    Salve a tutti. Non sto riuscendo a capire come impostare l'oggetto date() su una determinata data da me scelta. Mi spiego meglio:

    in una mia applicazione PHP utilizzo un calendario JS che, tra i parametri, prevede un oggetto Date() per preimpostare la data selezionata di default. Le date che utilizzo sono memorizzate in formato MySQL DATETIME, ma posso manipolarle come voglio.

    Ecco qui la porzione di codice con cui il calendario viene richiamato:

    codice:
    Calendar.setup({
    	inputField     :    "data_esame",     // id of the input field
    	ifFormat       :    "%Y-%m-%d %H:%M:00",     // format of the input field (even if hidden, this format will be honored)
    	displayArea    :    "vis_data_esame",       // ID of the span where the date is to be shown
    	daFormat       :    "%A %d %B %Y ore %H:%M",// format of the displayed date
    	align          :    "Bc",           // alignment (defaults to "Bl")
    	weekNumbers    :    false,        // disabilito i numeri di settimana
    	range          :    [2007,2008],
    	showsTime      :    true,
    	timeFormat     :    "24",
    	step           :    "1",
    	date           :    ,
    	dateStatusFunc :    function (date) { // disable weekend days (Saturdays == 6 and Subdays == 0)
    	                      return (date.getDay() == 0) ? true : false;
    	                    }
    });
    Nel parametro "date", attualmente vuoto, andrebbe la data da preimpostare, come da istruzioni:

    Type: date;

    This allows you to setup an initial date where the
    calendar will be positioned to. If absent then the
    calendar will open to the today date.
    Grazie a tutti, aspetto fiducioso!

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    non costava tanto provare... prova a mettere il parametro date come primo parametro, nel formato mese-giorno-anno (all'americana, per intenderci).

    codice:
    Calendar.setup(
        {
          date : "11-10-2007",
          // tutto il resto qui
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3
    Infatti non solo avevo già provato, ma ho cercato sul forum del progetto sourceforge, trovando molti post al riguardo ma nessuno con una soluzione; in uno di questi l'utente diceva di aver provato diversi tipi di stringa, nessuno funzionante.

    Inoltre nel reference manual si specifica che il tipo di questo parametro no è "string", ma "date"...

    Grazie comunque, resto in attesa.

  4. #4
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Se è il calendario di dynarch.com, quello è il modo e lo puoi benissimo vedere qui:

    http://andrea79.altervista.org/jscalendar/index.html

    Se non funziona, vuol dire che o non è lo stesso script, oppure sbagli qualcosa (e non avendo visto il tuo codice, non so aiutarti). Liberissimo di aspettare altri pareri.
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  5. #5
    Si, il calendario è proprio quello, nella versione popup che inserisce la data selezionata in un INPUT HIDDEN, mostrandola contemporaneamente in uno SPAN. Solo che non mi funziona il settaggio del parametro date:

    codice:
    <input type="hidden" name="data_esame" id="data_esame" />
    <span style="text-decoration: underline; cursor: pointer;" id="vis_data_esame">Clicca per modificare...</span>
    <script type="text/javascript">
        Calendar.setup({
            date           :    "08-16-2007",
            inputField     :    "data_esame",     // id of the input field
            ifFormat       :    "%Y-%m-%d %H:%M:00",     // format of the input field (even if hidden, this format will be honored)
            displayArea    :    "vis_data_esame",       // ID of the span where the date is to be shown
            daFormat       :    "%A %d %B %Y ore %H:%M",// format of the displayed date
            align          :    "Bc",           // alignment (defaults to "Bl")
            weekNumbers    :    false,        // disabilito i numeri di settimana
            range          :    [2007,2008],
            showsTime      :    true,
            timeFormat     :    "24",
            step           :    "1",
            dateStatusFunc :    function (date) { // disable weekend days (Saturdays == 6 and Subdays == 0)
                                  return (date.getDay() == 0) ? true : false;
                                }
        });
    </script>
    A parte impostare la lingua italiana (cambiando il suffisso del file JS incluso, da calendar-en.js a calendar-it.js) e settare gli altri parametri, non ho assolutamente messo mano al codice JS. E non capisco come mai non funzioni, mentre sulla tua pagina funziona!

  6. #6
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    ah, credo di aver capito... per caso così va?
    codice:
    <script type="text/javascript">
        Calendar.setup({
            dateStatusFunc :    function (date) { // disable weekend days (Saturdays == 6 and Subdays == 0)
                                  return (date.getDay() == 0) ? true : false;
                                },
            inputField     :    "data_esame",     // id of the input field
            ifFormat       :    "%Y-%m-%d %H:%M:00",     // format of the input field (even if hidden, this format will be honored)
            displayArea    :    "vis_data_esame",       // ID of the span where the date is to be shown
            daFormat       :    "%A %d %B %Y ore %H:%M",// format of the displayed date
            align          :    "Bc",           // alignment (defaults to "Bl")
            weekNumbers    :    false,        // disabilito i numeri di settimana
            range          :    [2007,2008],
            showsTime      :    true,
            timeFormat     :    "24",
            step           :    "1",
            date           :    "08-16-2007"      
        });
    </script>
    ho invertito le due definizioni
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  7. #7
    Purtroppo no... Il nuovo codice generato è questo:

    codice:
    <input type="hidden" name="data_esame" id="data_esame" />
    <span style="text-decoration: underline; cursor: pointer;" id="vis_data_esame">Clicca per modificare...</span>
    <script type="text/javascript">
        Calendar.setup({
            dateStatusFunc :    function (date) { // disable weekend days (Saturdays == 6 and Subdays == 0)
                                  return (date.getDay() == 0) ? true : false;
                                },
            inputField     :    "data_esame",     // id of the input field
            ifFormat       :    "%Y-%m-%d %H:%M:00",     // format of the input field (even if hidden, this format will be honored)
            displayArea    :    "vis_data_esame",       // ID of the span where the date is to be shown
            daFormat       :    "%A %d %B %Y ore %H:%M",// format of the displayed date
            align          :    "Bc",           // alignment (defaults to "Bl")
            weekNumbers    :    false,        // disabilito i numeri di settimana
            range          :    [2007,2008],
            showsTime      :    true,
            timeFormat     :    "24",
            step           :    "1",
            date           :    "8-16-2007"
        });
    </script>
    Ma nemmeno così funziona, quando appare il calendar è sempre impostato a oggi.

  8. #8
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    puoi mettere la pagina online?
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  9. #9
    Veramente gira sul mio server locale, si tratta di una componente di Joomla... Però posso mettere online una versione salvata... Ecco il link:

    http://scitrek.altervista.org/EXTERN...dar/index.html

    Dovrebbe contenere tutti i file e relativi JS e CSS. Grazie ancora!

    P.S.: per il momento ho risolto il problema in modo fittizio, come potresti vedere dal codice.

  10. #10

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.