Re[2]: Pre-selected date
2008/08/09 18:57
Viewed 4473 times
Replies: 1/6

Cheers for replying Barry G.

I'd noticed the date parameter in the Calendar documentation but I didn't go down that path. It's great for pre-selecting one date but I want to be able to pre-select more than one date, if the event in question has more than one date. Any idea's on how to achieve this?
As a plan b I decided to implement the 'high-light special dates' feature which is within the calendar docs. At least this way I can high-light multiple dates but its not quite what I'm looking for as the dates aren't themselves selected, they just have a different css class making them appear a different colour.
Any idea's anyone?

Cheers all the same!

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

last
Re[4]: Pre-selected date
2008/08/21 17:59
Viewed 5718 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
Google