Home › Forums › Backend Issues (wp-admin) › Change another field when Time picker field is changed › Reply To: Change another field when Time picker field is changed
There isn’t any documentation on how to update ACF fields in this manner. I have done some work with getting and setting values of ACF fields in JavaScript, but I have not worked with the date/time fields. With the date/time fields it’s not just a matter of setting a value, but also triggering the jQuery date picker to update correctly, or in some other way to make the change. I can tell you that the field that your targeting is only the displayed field. There is a hidden field that actually holds the value.
There may also be a problem with detecting that the first field is changed. Hidden fields to not trigger all of the same actions that other types of fields trigger. So your first step needs to be figuring out if your action firing at all. You can do this by logging something to the console to see if the action is getting triggered.
// JavaScript Document
(function($) {
$(document).ready(function(){
if (typeof acf == 'undefined') { return; }
$('#acf-field_5883db4f3d228').on('input', function() {
// do something
console.log('do something');
$('[data-name="report_time_end"] input.hasDatepicker').val( 'test' );
});
});
})(jQuery);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.