jQuery UI Widgets Forums Editors Calendar setDate not working on Calender widget

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • setDate not working on Calender widget #50190

    scott
    Participant

    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>';
    	}
    setDate not working on Calender widget #50191

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.