Jump to content

Datepicker multiple altField help


Recommended Posts

Good evening,


I have a jQuery datepicker that I am trying to insert different date values into different textboxes based on the user's selection. The original box displays the standard date format, input box 2 displays the date format suited for mysql, input box 3 needs to display the Month based on user selection, input box 4 displays the Year, and input box 5 needs to display the Month and the Year. The problem I am having is when I try to add multiple altField, it will only update the last id indicated. Here's my code.


Thanks in advanced,






<input type="text" id="Goal" name="Goal" value="<?php echo $Goal; ?>">
<input type="text" id="GoalDate" name="GoalDate" value="<?php echo $GoalDate; ?>">
<input type="text" id="MyBillsMonth" name="Month" value="<?php echo $Month; ?>">
<input type="text" id="MyBillsYear" name="Year" value="<?php echo $Year; ?>">
<input type="text" id="MyBillsMonthYear" name="MonthYear" value="<?php echo $MonthYear; ?>">



I've tried this

$( "#Goal" ).datepicker({
      changeMonth: true,
      changeYear: true,
 dateFormat: 'mm-dd-yy',
 altField: "#GoalDate, #MyBillsMonth, #MyBillsYear, #MyBillsMonthYear",
      altFormat: "yy-mm-dd, MM, yy, MM yy"

AND This

$( "#Goal" ).datepicker({
      changeMonth: true,
      changeYear: true,
 dateFormat: 'mm-dd-yy',
 altField: "#GoalDate",
      altFormat: "yy-mm-dd",
 altField: "#MyBillsMonth",
      altFormat: "MM",
 altField: "#MyBillsYear",
      altFormat: "yy",
 altField: "#MyBillsMonthYear",
      altFormat: "MM yy"

Link to comment
Share on other sites

You can only have one altField. Why do you think you need all these different input's anyway? At most you'd just need two inputs. One with a user-friendly format for display and the other hidden with a computer-friendly format. You can use the computer-friendly format to construct a date object and extract all the information you'd need for your other uses.

Link to comment
Share on other sites

I need the other fields updated in my database for other data and filtering that I am doing with the project.

So you've got 5 columns storing the same data in your database?


Is there anymore alternatives then?

Revisit your database set up.


Not trying to be a jerk, but if you're actually storing the same date value in 5 different formats in your table row, you're making everything so much harder on yourself and any time you may spend reading about database normalization is going to more than pay for itself in very little time.

Link to comment
Share on other sites

  • 3 weeks later...
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.

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.