[英]how to disable clicking of calendar after first click?[edited for solution]
我在应用程序中使用DHTML日历。 单击日期后,有一个表单提交操作。
我想在第一次单击后禁用日历,以使用户无法在提交表单之前单击其他日期。
我的代码是
<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]?>';
我为此解决了一个问题,我使用代码禁用了div和div的所有子级
**var nodes = document.getElementById("13-1_show_date").getElementsByTagName('*');
for(var i = 0; i < nodes.length; i++)
{
nodes[i].disabled = true;
}
submitForm();**
第一次单击后,此代码将禁用div及其子级。
此问题是经典问题,并且有很多方法:
isClciked
的临时变量,并在第一次单击时将其设置为true,然后在随后的单击中对其进行检查,如果为true,则只需return;
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.