codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to dynamically create a calendar when I click a button?  munwai at 06:58 on Monday, February 14, 2005
 

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(/forum/calendar_win2k_1.css);</style>
<script type="text/javascript" src="/forum/calendar.js"></script>
<script type="text/javascript" src="/forum/lang/calendar_en.js"></script>
<script type="text/javascript" src="/forum/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 = "/index.html" + y + "/index.html" + m + "/index.html" + d + "/index.html";
}
}
}

</script>
</div>




</body>


</html>

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

http://prdownloads.sourceforge.net/jscalendar/jscalendar-0.9.6.zip?download


Thanks in advance!

MW








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP
•  Remote Cart Shopping Cart
•  Mouse click coordinates on an ActiveX control?


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005