如何在第一次单击后禁用日历的单击?[已编辑解决方案]
我在我的应用程序中使用 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 及其子级。
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
<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
**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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题是一个经典问题,解决方法有很多种:
isClciked
的临时变量,并在第一次点击时将其设置为true,在后续点击中检查它,如果为true,则只需返回;
。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 simplyreturn;
.