我想在用户点击输入字段时弹出日历控件。日历控件实际上是日历的div部分,我试图切换显示。问题是当我点击输入时,日历不显示。但问题在于,当我将输入的位置属性从“相对”更改为“固定”时,日历显示出来,但相对于浏览器。我希望它相对于输入字段来显示。使用此JavascriptHTML输入弹出日历问题
function showCalendar(startDate)
{
try{
//var inputElement = document.getElementById(startDate);
var inputElement = document.getElementsByName(startDate)[0];
var divCalendar = document.getElementById('calendar');
var divContent = document.getElementById('content');
if(divCalendar.style.display == 'block')
{
divContent.appendChild(divCalendar);
//inputElement.style.position='fixed';
//divCalendar.style.position='fixed';
divCalendar.style.display = 'none';
//divCalendar.style.zindex = 0;
}
else
{
divCalendar.parentNode.removeChild(divCalendar);
inputElement.appendChild(divCalendar);
inputElement.style.position='relative';
divCalendar.style.position='absolute';
divCalendar.style.top=30;
divCalendar.style.left=30;
//divCalendar.style.zindex = 100;
divCalendar.style.display = 'block';
}
}
catch(e)
{
alert(e);
}
}
Book Rentals | |||
---|---|---|---|
Start Date | Start Time | ||
End Date | End Time | ||
Here is create a table dynamically which represent a calendar and which I am trying to toggle the display.