demeritrious Posted December 6, 2014 Share Posted December 6, 2014 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, Demeritrious HTML <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; ?>"> JQUERY 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" }); Quote Link to comment https://forums.phpfreaks.com/topic/292927-datepicker-multiple-altfield-help/ Share on other sites More sharing options...
kicken Posted December 6, 2014 Share Posted December 6, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/292927-datepicker-multiple-altfield-help/#findComment-1498783 Share on other sites More sharing options...
demeritrious Posted December 6, 2014 Author Share Posted December 6, 2014 I did that. I need the other fields updated in my database for other data and filtering that I am doing with the project. Is there anymore alternatives then? Quote Link to comment https://forums.phpfreaks.com/topic/292927-datepicker-multiple-altfield-help/#findComment-1498791 Share on other sites More sharing options...
maxxd Posted December 9, 2014 Share Posted December 9, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/292927-datepicker-multiple-altfield-help/#findComment-1499123 Share on other sites More sharing options...
demeritrious Posted December 27, 2014 Author Share Posted December 27, 2014 I figured out what I needed to do thank you for your advice though. I have everything working like I needed. Quote Link to comment https://forums.phpfreaks.com/topic/292927-datepicker-multiple-altfield-help/#findComment-1500759 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.