galvin Posted December 23, 2010 Share Posted December 23, 2010 I am implementing a JQuery Date Picker (http://docs.jquery.com/UI/Datepicker#option-altFormat). I am using the "altField" option so that a text field is displaying the "picked" date to the user. It's on a form that is submitted and often the user submits the form, but gets sent back to the form because they didn't fill other fields in completely. When this happens, I want the date they already picked to be shown in the display field (so they don't have to choose it again) rather than go back to being blank (which is what's happening now). Based on the info below, it sounds like I can use the "setter" code to set this altField to show a certain date. If that's wrong thinking, please correct me. If that's right, then how would I write that bit of code to show the date the user already picked, which I do have stored in a PHP variable called $_SESSION['thedate']? And furthemore, once I know the proper code, where exactly do I put that "setter" code? Does it have to be in the HEAD with the initial JQuery script code? Hope this makes sense altFieldType: Selector, jQuery, ElementDefault:''The jQuery selector for another field that is to be updated with the selected date from the datepicker. Use the altFormat setting to change the format of the date within this field. Leave as blank for no alternate field. Code examples //Initialize a datepicker with the altField option specified. $( ".selector" ).datepicker({ altField: '#actualDate' });Get or set the altField option, after init. //getter var altField = $( ".selector" ).datepicker( "option", "altField" ); //setter $( ".selector" ).datepicker( "option", "altField", '#actualDate' ); Quote Link to comment https://forums.phpfreaks.com/topic/222497-jquery-datepicker-show-already-chosen-date-when-user-is-sent-back-to-form-again/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.