Click to See Complete Forum and Search --> : Calendar code / Close
newtda
01-14-2004, 09:17 AM
Here is my code for my calendar. Now how would put a close link at the bottom of the calendar, so that when someone wants to get out of the calendar then can hit the close link. I tryed to search it but couldnt come up with anything.
Calendar Code:\
<html>
<head>
<style>
.cw {width:20px}
</style>
<script>
function a() {
document.getElementById('show_cal').style.visibility = 'visible';
}
</script>
</head>
<body>
<input type="text" name="txtDate">
<input name="button" type="button" onClick="a()" value="Calendar">
<div id ="show_cal" style="position: absolute; top: 51px; left:165px; border: solid; visibility:hidden; width: 151px; height: 26px;">
<div class="close">Cancel</div>
<script>
ms = 5;
dm = 31;
d = 1;
for (i=1; i<=42;i++){
if ( i >= ms && d <=dm)
{
html ="<input type='text' class='cw' value=" + d + ">";
d++;
}
else
{
html = "<input type='text' class='cw'>";
}
document.write(html);
if (i % 7 == 0){
document.write("<br>");
}
}
</script>
</div>
</body>
</html>
This would have been best posted in the JavaScript section...
Anyway, you can close a window (I'm assuming that is what you want to do) with window.close().
newtda
01-14-2004, 09:34 AM
yes, I want to have the user close out of the calendar. Should put the calendar name in the brackets.
newtda
01-14-2004, 09:39 AM
that is all i want the user to do is close out of the calendar when there done looking at the calendar.
Ah, ok... For some reason I thought you had further questions. :)
newtda
01-14-2004, 09:43 AM
nope, but if you are willing to help me out some more on this situation and you have aol insant messenger im me at newtda21.
No, I don't have AIM, but if you post your questions, they'll probably get answered.
newtda
01-14-2004, 09:49 AM
ok cool, when i use this line of code:
<a href= "javascript:window.close"()">Close</a>
I get this message:
function close() { [native code] }
fredmv
01-14-2004, 09:54 AM
That's because it's returning the last return value since you're using the JavaScript pseudo-protocol (which you should not be — it's supposed to be for bookmarklets). There are two solutions: Add void 0 to the end of the JavaScript in order to supress any return values (not recommended). Write it correctly using an event handler (recommended):<a href="#" onclick="self.close();">Close</a>
newtda
01-14-2004, 09:58 AM
that just closes out that closes out of the whole browser window. I just need the calendar to go away.
fredmv
01-14-2004, 10:00 AM
I guess you're going to have to be more specific as to how you have this implemented. If the calender opened in a new window, and you used the code I previously provided in it, that should suit your needs.
newtda
01-14-2004, 10:10 AM
Here is what I have. When you click on the close link the whole page closes down. I am trying to get it to when you click close just the calendar goes away and the you just see the text box and the button on the screen.
code:
<html>
<head>
<style>
.cw {width:20px}
</style>
<script>
function a(a) {
document.getElementById('show_cal').style.visibility = 'visible';
}
</script>
</head>
<body>
<input type="text" name="txtDate">
<input name="button" type="button" onClick="a()" value="Calendar">
<div id ="show_cal" style="position: absolute; top: 51px; left:165px; border: solid; visibility:hidden; width: 151px; height: 26px;">
<script>
ms = 5;
dm = 31;
d = 1;
for (i=1; i<=42;i++){
if ( i >= ms && d <=dm)
{
html ="<input type='text' class='cw' value=" + d + ">";
d++;
}
else
{
html = "<input type='text' class='cw'>";
}
document.write(html);
if (i % 7 == 0){
document.write("<br>");
}
}
</script>
<a href="#" onclick="self.close();">Close</a>
</div>
</body>
</html>
fredmv
01-14-2004, 10:21 AM
<a href="#" onclick="parentNode.style.visibility='hidden';">Close</a>
newtda
01-14-2004, 10:26 AM
Thank you so much. Now I get move on and make the numbers buttons. I am not going to bug you with this one. I will try to figure it out on my own and if I cant get I dont use the calendar.