Thursday, April 30, 2009

[jQuery] Problem w/ Time picker plugin

Hello,

I'm implementing this Jquery time picker: (http://plugins.jquery.com/
project/pttimeselect
) and It works perfectly until I try to add a php
var to the value of the input tag.

Here's my form code:

[code]
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<div id="time_of_day_select">
<label for="time_of_day-field" >Time of Day</label>
<input name="time_of_day" id="time_of_day_select" value="<?php
echo $presc_data['time_of_day'] ?>" />
</div>
<input type="submit" name="submit" value="Save" />
</form>
[/code]


Here's my time picker instantiation:
[code]
<script language="JavaScript">
<!--
$(document).ready( function () { $('#time_of_day_select
input').ptTimeSelect(); });
//-->
</script>
[/code]


The datepicker works perfectly when I don' t add the php var to the
input value:

This works:
[code]
<input name="time_of_day" id="time_of_day_select" value="" />
[/code]

This breaks the Time Picker:
[code]
<input name="time_of_day" id="time_of_day_select" value="<?php echo
$presc_data['time_of_day'] ?>" />
[/code]

This also throws this error in ptTimeSelect.js:

match is null
[Break on this error] hr = match[1] || 1;

Seems like this is a very common need and there should be a simple
solution I'm missing.

Thanks,
Clem C

No comments: