I have been Googling this for a while now, a brief back ground I am a novice at PhP and a newbie on JQuery UI. I appreciate the PhP I am using is now depricated however I am "fixing" up a MySQL database UI for work to make my life easier (in the long run) hence the reason I taught myself PhP in the first place (work does not have any cash to get it fixed and there response is Oh well rewrite the whole thin using a excel spreadsheet. The closest fix I could find was a post here How can I pass PHP variable to Datepicker in jQuery?
However no joy. I have no issues using it to Create / Read and Delete my problem comes with update as the existing data is not assigned to the JQuery id to input. The variable I am using works to populate to text box just not the value that is posted.....grrr! My whole script is 1900 lines long so hopefully posting the relevant bits will be enough. My header Jquery code and my update code from my form:
enter code here
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness /jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<!-- 3 datepicker javascripts -->
<script> language ="javascript">
$(function() {
$( "#datepicker" ).datepicker();
$('#userDatedr').datepicker({dateFormat:"dd MM yy",
altField: '#drDate', altFormat: 'yy-mm-dd'});
//Set javascript date to php variable
var phpDate = "<?php echo $grab_staff[driver_exp]?>";
});
$("#drDate").datepicker("setDate",phpDate);
</script>
<?php
<body>
<html>
print("<tr><td id='employee_left'>Drivers Licence:</td><td>
<b>Number:</b> <input type='text' name='driver_num' value='$grab_staff[driver_num]' maxlength='15' /><br />");
print("<tr><td id='employee_left'><b>Expiry:</b> </td><td> <input type= 'text' value='$grab_staff[driver_exp]' id=\"userDatedr\" maxlength='10'><input type=\"text\" id=\"drDate\" name=\"drDate\">");
?>
</body>
</html>
To clarify, datepicker works when editing if I select a new date, i want to be able to re-post the existing date from the data base and update without the user having to select the date again from the datepicker calendar keeping in mind this form has 4 different date fields, date of birth, drivers license expiry date, original induction date and last induction date. The current fields above the code refers to is the drivers expiry date. The value that is posted will be changed from text to hidden once I have finished fault finding so at present it gives two fields, the first field displays the original date from the date base, which if edited with datepicker changes to the new date the second text box which will be hidden is blank if the date is not changed using the datepicker. Any help / suggestions will be appreciated Cheers
Jase