Re[3]: Pre-selected date
2008/08/19 19:14
Viewed 4828 times
Replies: 1/5

Try this...

<?php
$con=mysql_connect("localhost","<usr>","<pwd>");
mysql_select_db("<db>",$con);

$sql="SELECT * FROM <table>";
$result = mysql_query($sql);

$date = '[ ';
while($row = mysql_fetch_array($result)){
$date .= "new Date('".date("Y/m/d",$row['<timestamp field>'])."'), ";
}
$date .= ' ]';
//echo $date;
?>

Calendar code start...

<script type="text/javascript">//<![CDATA[
// the default multiple dates selected, first time the calendar is instantiated
// MA = [ new Date('2008/08/21'), new Date('2008/08/22'), new Date('2008/08/20'), ] ;
MA = <?php echo $date; ?>;

... calendar code continuing ...

/B

Re[4]: Pre-selected date
2008/08/21 17:59
Viewed 5719 times
Replies: 1/4

Hello, all:

I am new to the user of this wonderful calendar widget, but I am stuck at using the "date" parameter. It does not work for me. Here is what I tried:

<html:text property="clockInSaturday" styleId="clockInSaturdayId" style="width: 20%;" />
<script type="text/javascript">
function calculateTodaysDate( dayName ) {
Date date = new Date( );
date.setDate( 21 ); // This is Thursday for example
date.setMonth( 7 );
date.setFullYear( 2008 );
var time = date.getTime( );
var oneDay = ((1000 * 60) * 60) * 24;

if( dayName == "Saturday" ) {
time -= (oneDay * 6); // Subtract 6 days, would that be Sat in the week ending on Fri, or Sat after Fri (next week)?
date.setTime( time );
return date;
}

if( dayName == "Sunday" ) {
time -= (oneDay * 5); // Subtract 5 days
date.setTime( time );
return date;
}

// Similarly I have 5 more checks for the other 5 days of the week

return date;
}

Calendar.setup(
{
inputField : "clockInSaturdayId",
ifFormat : "%H:%M",
showsTime : true,
timeFormat : "24",
firstDay : 6, // Display Saturday as the first day
date : calculateTodaysDate( "Saturday" ),
weekNumbers : false
} );
</script>

Actually, my problem is 3-fold. I want the user to enter just the hour-minute (no date), that's why I chose iFormat as "%H:%M". But the problem is that when the calendar opens, the default date is today's date and the user cannot change it if he wants to - he can only select hour-minute and enter it - that's problem # 1. The calendar with default today's date will look confusing and misleading to the user if he wants to enter time for some other date. So I tried to use the "date" parameter, but the calendar does not appear no matter how much I click in the field - that is problem # 2. What's wrong with my code?

Problem # 3: In the calculateTodaysDate function above I hard-coded a date as 08/21/2008 (Thursday) just for example. Actually, my JSP page, where I set up the above calendar, gets a weekend date (Java Date object) as a form parameter. How does the above function get DAY, MONTH, and YEAR out of that Java Date object, so it can create its own JavaScript Date object for further processing? How else would I let the user select just the time (for the right date) and display the entry as time too?

Please help. Thanks a lot in advance.

last
Re[5]: Pre-selected date
2008/08/22 16:46
Viewed 6746 times
Replies: 1/3

I solved all my 3 problems, including the "date" parameter problem. I modified the script calendar-setup.js and the "date" parameter worked like a charm. It is high time the developers in charge of this calendar widget fixed the script, because otherwise all downloaders will continue to waste their time in trying to figure out why the "date", "displayArea", and "daFormat" parameters do not work. I ended up wasting 3 full days on this before I found out the defect in calendar-setup.js script, thanks to another post hidden deep on this forum.

last
Google