[英]how to disable clicking of calendar after first click?[edited for solution]
i am using an DHTML calendar in my application. 我在应用程序中使用DHTML日历。 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 我的代码是
<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]?>';
i made a solution for this i disabled div and all the children of div using the code 我为此解决了一个问题,我使用代码禁用了div和div的所有子级
**var nodes = document.getElementById("13-1_show_date").getElementsByTagName('*');
for(var i = 0; i < nodes.length; i++)
{
nodes[i].disabled = true;
}
submitForm();**
this code will disable the div and its childrens after first click. 第一次单击后,此代码将禁用div及其子级。
This problem is a classical problem, and there are many ways: 此问题是经典问题,并且有很多方法:
isClciked
and set it to true in the first click, and in subsequent clicks, check it, and if it's true, then simply return;
isClciked
的临时变量,并在第一次单击时将其设置为true,然后在随后的单击中对其进行检查,如果为true,则只需return;
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.