jQuery UI Widgets › Forums › General Discussions › Editors › Calendar › setDate not working on Calender widget
Tagged: date picker, javascript date, setdate method
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 11 years, 8 months ago.
-
Author
-
Hi guys,
I’ve been looking over these forums and from what I can tell I’m following the right syntax for setDate but every time I create a widget and try to set the date it always defaults to today. Would you mind taking a look at my code and seeing if I’m doing something wrong? I’m creating several calender widgets depending on if the database name is ‘date’ or ‘time’ and then creating a unique name for that widget based on the counter. Thanks much any help you can provide!
if ( strstr($temp_name1, "date") || strstr($temp_name1, "time") || $temp_name1=="DOB") { $datesql="SELECT DATE_FORMAT($temp_name1, '%Y, %m, %d, %H, %i, %s, 0') setdate from $source_table where lm_info_id = $lm_info_id"; $dateresults=mysql_query($datesql); $daterow=mysql_fetch_assoc($dateresults); $setrow=$daterow['setdate']; print '<td style="width: 100px;'.$offset.'">'; print'<div id=\'content'.$counter.'\' style="height:0px; width:0px; padding-top: 0px;padding-right: 0px; padding-bottom: 0px;padding-left: 0px; margin-right:0; margin-left: 0; margin-top: 0;" > <script type="text/javascript"> $(document).ready(function () { // Create a jqxDateTimeInput $("#jqxWidget'.$counter.'").jqxDateTimeInput({ width: \'300px\', height: \'25px\', formatString: \'F\' }); }); $(\'#jqxWidget'.$counter.'\').jqxDateTimeInput(\'setDate\', new Date ('.$setrow.')); </script> <div id=\'jqxWidget'.$counter.'\'> </div> </div>'; print '</td>'; }Hi scott,
The JavaScript Date object has specific syntax. I do not know what is ‘.$setrow.’, but if it is a String, then it would not work as the Date object’s constructor expects other values. If you look at the widget’s API Documentation about setDate, you will find this sample: http://jsfiddle.net/jqwidgets/3UguZ/, which shows how to use the method. To learn more about JavaScript Date, you may also look at: http://www.w3schools.com/js/js_obj_date.asp
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.