Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2009
    Messaggi
    206

    Problema visualizzazione calendario

    Ciao a tutti, ho creato una pagina html che ha un determinato template. all'interno del body ho creato un form che permette, attraverso un calendario creato con javascript, di selezionare una data.

    codice:
    <form action="#">           
    
    Data:              <input type="text" name="date3" id="sel3" size="30">             <input type="reset" value=" ... " onclick="return showCalendar('sel3', '%d/%m/%Y');">           </p>         </form>
    Il problema è che il calenderio mi viene visualizzato sotto la pagina e non immediatamente sotto il tasto con i tre puntini.

    Qualche idea?

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    puo' dipendere da vari motivi
    senza vedere (tutta) la tua pagina non ha senso tirare a indovinare

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2009
    Messaggi
    206
    codice form:

    codice:
    <form action="#">
    Data: <input type="text" name="date3" id="sel3" size="30">
    <input type="reset" value=" ... " onclick="return showCalendar('sel3', '%d/%m/%Y');">
    <input name="Elabora" type="submit" value="Elabora" id="Elabora"/>
    </form>
    nell'header ho messo:

    codice:
    <link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="Aqua" />
    <script type="text/javascript" src="calendar.js"></script>
    <script type="text/javascript" src="calendar-it.js"></script>
    
    <script type="text/javascript">
    
    var oldLink = null;
    function setActiveStyleSheet(link, title) {
      var i, a, main;
      for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
        if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
          a.disabled = true;
          if(a.getAttribute("title") == title) a.disabled = false;
        }
      }
      if (oldLink) oldLink.style.fontWeight = 'normal';
      oldLink = link;
      link.style.fontWeight = 'bold';
      return false;
    }
    
    // This function gets called when the end-user clicks on some date.
    function selected(cal, date) {
      cal.sel.value = date; // just update the date in the input field.
      if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
        cal.callCloseHandler();
    }
    
    function closeHandler(cal) {
      cal.hide();                        // hide the calendar
    //  cal.destroy();
      _dynarch_popupCalendar = null;
    }
    
    function showCalendar(id, format, showsTime, showsOtherMonths) {
      var el = document.getElementById(id);
      if (_dynarch_popupCalendar != null) {
        // we already have some calendar created
        _dynarch_popupCalendar.hide();                 // so we hide it first.
      } else {
        // first-time call, create the calendar.
        var cal = new Calendar(1, null, selected, closeHandler);
        // uncomment the following line to hide the week numbers
        // cal.weekNumbers = false;
        if (typeof showsTime == "string") {
          cal.showsTime = true;
          cal.time24 = (showsTime == "24");
        }
        if (showsOtherMonths) {
          cal.showsOtherMonths = true;
        }
        _dynarch_popupCalendar = cal;                  // remember it in the global var
        cal.setRange(1900, 2070);        // min/max year allowed.
        cal.create();
      }
      _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
      _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
      _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
    
      _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
    
      return false;
    }
    
    var MINUTE = 60 * 1000;
    var HOUR = 60 * MINUTE;
    var DAY = 24 * HOUR;
    var WEEK = 7 * DAY;
    
    function isDisabled(date) {
      var today = new Date();
      return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
    }
    
    function flatSelected(cal, date) {
      var el = document.getElementById("preview");
      el.innerHTML = date;
    }
    
    function showFlatCalendar() {
      var parent = document.getElementById("display");
    
      var cal = new Calendar(0, null, flatSelected);
    
      cal.weekNumbers = false;
    
      cal.setDisabledHandler(isDisabled);
      cal.setDateFormat("%A, %B %e");
    
      cal.create(parent);
    
      cal.show();
    }
    </script>
    dove i due file calendar.js e calendar-it.js insieme al css skins/aqua/theme.css li ho scaricati al seguente link:

    download calendario

    Il fatto è che se io tolgo il pulsante elabora dal form, allora il calendario mi viene visualizzato sotto il bottone con i 3 punti altrimenti no! Però a me quel tasto elabora serve perchè la data prescelta la devo passare ad uno script che me la elabori.

  4. #4

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2009
    Messaggi
    206
    Grazie mille. Non avevo trovato il topic già aperto.
    A questo punto ti chiedo un altro dubbio:

    nel mio form ho scritto il seguente codice:

    codice:
    <input type="reset" value=" ... " onclick="return showCalendar('sel3', '%d/%m/%Y');">
    tuttavia a me servirebbe che premendo sul tasto "Elabora" mi venga richiamato uno script python che mi legga la data inserita me la converta nel formato che desidero e mi restituisca il valore generato in un casella del form corrente! Ho pensato di utilizzare AJAX in modo da far si che il form sia dinamico e che mi possa gestire la risposta generata dallo script python.
    Posso usare una dicitura di questo tipo?:

    codice:
    <input type="reset" value=" ... " onclick="return showCalendar('sel3', '%d/%m/%Y');" onsubmit="invio(); return false;">
    grazie

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.