views:

143

answers:

1

I'm having troubles with the following code:

<link type="text/css" href="http://jqueryui.com/latest/themes/base/jquery.ui.all.css" rel="stylesheet" />

<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.4.2.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/1.8rc1/jquery-1.4.1.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/1.8rc1/ui/jquery-ui.js"&gt;&lt;/script&gt;
<script type="text/javascript">
  $(document).ready(function(){
      $("#datepicker").datepicker({ gotoCurrent: false,
          onSelect: function(date, inst) { window.location = "diary.php?date="+date; },
          dateFormat: 'dd-mm-yy',
          defaultDate: <?php if(isset($_GET['date'])) { echo $_GET['date']; } else { echo "null"; } ?>
      });
  });
</script>

For some reason, when I select a date and switch pages - it doesn't go to the defaultDate that is in the $_GET['date'] paramter. Instead it goes off to some random page. The defaultDate description says it will accept strings in the same format set in the code.

Thanks in advance for any help.

+1  A: 

I think you are missing quotes around your value.

defaultDate: '<?php if(isset($_GET['date'])) { echo $_GET['date']; } else { echo "null"; } ?>'
Pekka
Wow you got it. Such a stupid error. Cheers mate.
Danny