Hack Forums
how to disable clicking of calendar after first click? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: how to disable clicking of calendar after first click? (/showthread.php?tid=1994559)



how to disable clicking of calendar after first click? - mysteriousmyster - Dec 9, 2011

i am using an DHTML calendar in my application. on clicking a date ,there is a form submit action.

i want to disable the calendar after first click ,so that user can not click the other date before the form submit.

my code is

PHP Code

<?php 
<SCRIPT type="text/javascript">

    function 
dateChanged(calendar) 
    {
        
// Beware that this function is called even if the end-user only
        // changed the month/year. In order to determine if a date was
        // clicked you can use the dateClicked property of the calendar:
        
if (calendar.dateClicked) {
        
// OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
        
var y = calendar.date.getFullYear();
        var 
m = calendar.date.getMonth() + 1; // integer, 0..11
        
var d = calendar.date.getDate(); // integer, 1..31
        
var NewDate = y + "-" + m + "-" + d;
        
document.getElementById("<?=$mydata[FILTER]?>").value = NewDate;
        
submitForm();
    }
        
                                                    
                          
                        
        var 
tempDate = new Date(<?=$CalDate?>);
        Calendar.setup({
                flat        : "<?=$mydata[FILTER]?>_show_date",      // ID of the parent element
                flatCallback:dateChanged,                                             // our callback function
                weekNumbers:false,                                                 // Don't display week numbers
                date        : tempDate      
                        // Set calendar to start at selected date
            });
                        
        document.getElementById("<?=$mydata[FILTER]?>").value = '<?=$mydata[FILTER]?>';
</script>