Search the Community
Showing results for tags 'datepicker'.
-
Hello -I'm trying to build a datepicker which only allows certain dates in my database to be selected.. Below are the codes...and the datepicker widget shows up but the "AvailableDate" (which is listed in the database as "2012-05-09") are not showing up in different color. Please can someone help to see where the error is? Thank you! [left]<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> <link href="css/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script> <script type = "text/javascript"> $(function(){ $.ajax({ url: "dates2.php", data: "action=showdates&id=1", dataType: "json", success: function(calendarEvents){ $(".calendarwidget").datepicker({ // [rows, columns] if you want to display multiple calendars. numberOfMonths: [1, 1], showCurrentAtPos: 0, beforeShowDay: function (date){ for (i = 0; i < calendarEvents.length; i++) { if (date.getMonth() == calendarEvents[i][0] - 1 && date.getDate() == calendarEvents[i][1] && date.getFullYear() == calendarEvents[i][2]) { //[disable/enable, class for styling appearance, tool tip] return [false,"ui-state-active","Event Name"]; } } return [true, ""];//enable all other days } }); } }); }); </script> </head> <body> <div class="calendarwidget"><!--calender widget is loaded here--> </div> </body> </html>[/left] [left] [/left] <?php [left]//DB CONFIG $hostname_logon = '***'; //Database server LOCATION $database_logon = '****'; //Database NAME $username_logon = '***'; //Database USERNAME $password_logon = '***'; //Database PASSWORD //Table config $tablename = "venue_room_availability"; //Name of the DB table $event_id = "AvailableID"; //Primary Key field of the table //Connect to the DB $connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ('Unabale to connect to the database'); mysql_select_db($database_logon) or die ("Error in query: $qry. " . mysql_error()); /****** Bread & Butter *************/ $action = $_REQUEST['action']; switch ($action){ case 'showdates': $qry = "SELECT * FROM ".$tablename.""; $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error()); echo '['; while($row = mysql_fetch_assoc($result)); //$row['AvailableDate'] =rtrim($row['AvailableDate'], ","); echo $row['AvailableDate']; echo ']'; break; } ?>[/left] [left] [/left]
- 4 replies
-
- datepicker
- jquery
-
(and 2 more)
Tagged with: