Jump to content

JQuery DatePicker show already chosen date when user is sent back to form again?


galvin

Recommended Posts

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' );

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.