» Forums
» The DHTML Calendar
» General discussion
» Using Calendar With Separate Form Fields For Y/M/D etc.
Using Calendar With Separate Form Fields For Y/M/D etc.
2005/01/17 12:35
Viewed 14051 times
Replies: 1/1

I'm trying to adapt The DHTML Calendar for use with Textpattern which has separate form fields for year, month, day, hour, and minute. Can I have The Calendar output to the separate fields all at once? If so, how do I do it?

Thanks for such a cool calendar!

  • jeff
Re: Using Calendar With Separate Form Fields For Y/M/D etc.
2006/05/12 22:46
Viewed 11873 times
Replies: 0/0

Try this:

<input type="text" name="month" id="f_date_a" size="2"/>/
<input type="text" name="day" id="f_date_b" size="2"/>/
<input type="text" name="year" id="f_date_c" size="4"/>
<input type="reset" id="f_trigger_b" value="...">

<script type="text/javascript">
function catcalc(cal) {
var date = cal.date;

var field = document.getElementById("f_date_b");
field.value = date.print("%d");

field = document.getElementById("f_date_c");
field.value = date.print("%Y");
}
Calendar.setup({
inputField : "f_date_a",
ifFormat : "%m",
button : "f_trigger_b",
onUpdate : catcalc
});
Calendar.setup({
inputField : "f_date_b",
ifFormat : "%d"
});
Calendar.setup({
inputField : "f_date_c",
ifFormat : "%Y"
});
</script>

This will populate the first box with the month, then use the onUpdate to populate the other 2 boxes with the day and year of the selected date.

last
Google