All pastes #437156 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-12 22:10 UTC
rendered paste body
<script>
        YAHOO.namespace("example.calendar");

        YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container", { title:"Choose a date:", close:true } ); 
        YAHOO.example.calendar.cal1.render(); 

        function handleSelect(type,args,obj) {
                var dates = args[0]; 
                var date = dates[0];
                var year = date[0], month = date[1], day = date[2];
                
                var txtDate1 = document.getElementById("id_start_date");
                txtDate1.value = month + "/" + day + "/" + year;
        }

        function updateCal() {
                var txtDate1 = document.getElementById("id_start_date");

                if (txtDate1.value != "") {
                        YAHOO.example.calendar.cal1.select(txtDate1.value);
                        
                        var firstDate = YAHOO.example.calendar.cal1.getSelectedDates()[0];
                        YAHOO.example.calendar.cal1.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear());
                        YAHOO.example.calendar.cal1.render();
                }
        }

        // For this example page, stop the Form from being submitted, and update the cal instead
        function handleSubmit(e) {
                updateCal();
                YAHOO.util.Event.preventDefault(e);
        }

        function init() {
                YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container", 
                { mindate:"1/1/2006",
                  maxdate:"12/31/2008" });
                YAHOO.example.calendar.cal1.selectEvent.subscribe(handleSelect, YAHOO.example.calendar.cal1, true);
                YAHOO.example.calendar.cal1.render();

                YAHOO.util.Event.addListener("update", "click", updateCal);
                YAHOO.util.Event.addListener("dates", "submit", handleSubmit);
        }

        YAHOO.util.Event.addListener("show1up", "click", YAHOO.example.calendar.cal1.show, YAHOO.example.calendar.cal1, true); 

</script>


    <td> {{ form.start_date }}
      <button id="show1up">Show a single Calendar</button>
      <div id="cal1Container"></div>
    </td>