Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to dynamically create a calendar when I click a button?

Status
Not open for further replies.

munwai

Programmer
Feb 13, 2005
2
AU
Hi all,

I am trying to dynamically create a calendar when I click on a button and the calendar should dissapear when I click out of it. So far I have the following code but it is not working the way I want it to.

<html>
<head>


<style type="text/css">@import url(calendar-win2k-1.css);</style>
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar-setup.js"></script>

<script type="text/javascript">


function onSelect(calendar, date) {
var input_field = document.getElementById("date");
input_field.value = date;
if (calendar.dateClicked) {
calendar.callCloseHandler(); // this calls "onClose"
}
}

function onClose(calendar) {
calendar.hide();
// or calendar.destroy();
}



</script>
</head>

<body>
<form name = MainForm>

<div id="d">

Date:<input type="text" name="date">
<input type="button" name="calButton" onclick="run()" value="...">
<div id="calendar-container"></div>

<script type="text/javascript">

function run() {
Calendar.setup(
{
flat : "calendar-container", // ID of the parent element
flatCallback : dateChanged // our callback function
}
)
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(); // integer, 0..11
var d = calendar.date.getDate(); // integer, 1..31
// redirect...
window.location = "/" + y + "/" + m + "/" + d + "/index.php";
}
}
}

</script>
</div>




</body>


</html>

I am using the scripts from a JSCalendar which can be downloaded from



Thanks in advance!

MW
 
I suggest you contact the person who originally wrote the script you are attempting to use... and ask them for technical support. If you are unable to get help from them, then you may be better off finding another calendar script that is better supported.

Do you know how to code in Javascript - or do you just implement other people's scripts? If you do not know how to code Javascript then posting here is just going to confuse you.

Jeff
 
I've used the same calendar and had no problem. WHAT is it you want it to do, and what IS or ISN'T it doing correctly?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hm..I think I got confused with it before this..starting to understand it better now..thanks for the responds anyway =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top