did anyone know how to make a calendar by using javascript? actually i want to put calendar next to text field, so that, the user can easily select the date and the date will come out in the text field......help me plzzz.....

Dani AI

Generated

Quick diagnosis (based on ’s report and the samples from and ): the calendar opens but the picked date never appears in the textbox. That almost always means the calendar script never finds the input or the trigger element at the moment the handler is attached, or the click is following a real link instead of being intercepted by the calendar setup.

Checklist of the most common causes and how to check them

  • IDs vs names: the calendar looks up elements by their HTML id. An input with only a name attribute (or an id containing spaces like the literal id of field) will fail. Inspect the rendered HTML (DevTools → Elements) and confirm the textbox has a simple, unique id (no spaces, start with a letter).
  • Timing: if the Calendar.setup call runs before the form markup exists, handlers won’t attach. Either put the setup after the form in the page or run it on DOMContentLoaded/window.onload.
  • Missing scripts or JS errors: open the Console and Network tabs. A 404 for calendar JS or any JavaScript error will stop the setup code from running.
  • Trigger element is a real link or a submit control: if the calendar trigger is inside an <a href="..."> or a submit button, clicking may navigate/submit instead of opening and writing back. Use a plain image/button or remove the link behavior.

Minimal markup pattern to verify (note the id names — no spaces):

<input id="dateField" name="date" type="text">
<img id="dateTrigger" src="images/ew_calendar.gif" alt="Pick a date" style="cursor:pointer">

If the minimal standalone page with the calendar files works but the full page doesn’t, a conflicting script or framework (ASP.NET client-id rewriting, other libraries) is likely interfering. In that case inspect the final rendered ids and any JavaScript errors, then adjust the setup to target the actual client-side id or use a safe client-id mode. For a quick modern alternative (if starting fresh), HTML5 input type="date" or a maintained widget such as jQuery UI Datepicker avoids many of these integration pitfalls.

Recommended Answers

All 3 Replies

Put the attached folder in the folder in which your application resides. Then Insert the following javascript above the code for your form.

<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>

Then put the following code just after the code in form where you are making textbox for calendar.

&nbsp;<img src="images/ew_calendar.gif" id="id of field" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
  <script type="text/javascript">
Calendar.setup(
{
inputField : "id of date field", // ID of the input field
ifFormat : "%Y/%m/%d", // the date format
button : "button id" // ID of the button
}
);

Hey find this attachment...
Its simple and fine...

to shanti....thanks for ur attachment and info.....but, i got a problem...when i click on the date, the date will not reside the text field.....here, the attachment....the page come out on the calendar....why is that happened? i'll send u my coding.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.