Forum Moderators: open
However, I'd also like the calendar to close (without doing anything) if you click anywhere else on the page. I tried putting an onBlur in the input element, which works, except that if I click on the calendar, the onBlur causes it to close before the click causes the input field to update.
I tried a cover-like method where there's a transparent div covering the whole page, behind the calendar widget but above the main divs, so that if you click anywhere, the cover intercepts the click and closes the div. However this means you have to click twice to focus any other element, and it also means the scrollwheel doesn't work while the cover div is up.
(FYI, the input field pops up the calendar on an onClick event. I also tried onFocus, with the same results as above.)
If anyone has any advice or suggestions, I'd greatly appreciate it. Thanks!
Opening window:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Close Window</title>
<script type="text/javascript">
function newWin(url) {
var day = new Date();
var id=day.getTime();
var params = 'width=400,height=400,scrollbars,resizable';
var win=open(url,id,params);
return false;
}
</script>
</head>
<body>
<form>
<input type="text" id="txtfld" onClick="return newWin('win.html');">
</form>
</body>
</html>
Pop up:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
<script type="text/javascript">
window.onload=function() {
document.getElementById('txtfld').onblur=function() {
window.opener.document.getElementById('txtfld').value=
document.getElementById('txtfld').value;
window.close();
}
}
</script>
</head>
<body>
<form>
<input type="text" id="txtfld">
</form>
</body>
</html>
Initially misunderstood problem, this should do it . . .