Forums

Take value from calendar field

webcrea 29 Jan, 2019
hi,

Calendar field is very strange !! Impossible to take his value in javascript, why?

After change, I want extract the year and put it in another field text in javascript... How can i do that ?

Thanks
And one more, when bugs will be solve?
healyhatman 29 Jan, 2019
What "bugs" ?

For the calendar field, you need
jQuery("input[type='hidden'][name='calendar_name']").val()
webcrea 30 Jan, 2019
Hello healy,

code html :
<input name="fiche[dateAgrement]" value="2018-09-12" data-events="[]" data-firstday="0" data-startmode="day" data-type="date" data-dformat="DD/MM/YYYY" data-sformat="YYYY-MM-DD" data-mindate="" data-maxdate="" data-opendays="" data-openhours="" data-startcalendar="" data-endcalendar="" data-popuppos="top center" data-ampm="0" placeholder="" id="dateAgrement" type="text" data-calendar="1" class="">

code js :
dateAgrement = jQuery("input[type='hidden'][name='fiche[dateAgrement]']");
console.log("date " + dateAgrement.val());

produces in the console :
date undefined

Regards
healyhatman 30 Jan, 2019
Works for me.
jQuery('button[name="button4"]').click(function() { console.log("DATE: " + jQuery('input[type="hidden"][name="calendar[tester]"]').val()); });
webcrea 31 Jan, 2019
it doesn't work with me :-(
but i try this

jQuery(document).ready( function() {
dateAgrement = jQuery("#dateAgrement");

console.log( "DATE: " + jQuery('input[type="hidden"][name="fiche[dateAgrement]"]').val() ); --> undefined
console.log( "id DATE: " + jQuery(dateAgrement).val() ); --> 2018-09-12
jQuery(dateAgrement).on('change', function(){ --> event is in console[event] for this but nothing in console after change it
console.log( "id DATE: " + jQuery(dateAgrement).val() );
});
});2018-09-12

<input id="dateAgrement" name="fiche[dateAgrement]" value="2018-09-12" data-events="[]" data-firstday="0" data-startmode="day" data-type="date" data-dformat="DD/MM/YYYY" data-sformat="YYYY-MM-DD" data-mindate="" data-maxdate="" data-opendays="" data-openhours="" data-startcalendar="" data-endcalendar="" data-popuppos="top center" data-ampm="0" placeholder="" id="dateAgrement" type="text" data-calendar="1" class="">

<input type="hidden" name="fiche[dateAgrement]" value="2018-09-11">
healyhatman 31 Jan, 2019
It won't get the value on document ready, that just means the DOM is built, none of the other CF code has happened yet.
healyhatman 31 Jan, 2019
And again using the id won't help you you need the code I gave you to get the value from the hidden input field that holds the value.
webcrea 31 Jan, 2019
I see the CF code attached to the input
webcrea 31 Jan, 2019
with i can populate the value of the input. that means js see and isolates the input and js attached the event but it seems like a non-propagation somewhere stop the effect.. Sorry for my english
healyhatman 31 Jan, 2019
Send me access details and I'll look
webcrea 31 Jan, 2019

This is private content

healyhatman 31 Jan, 2019
PM it to me I can't see that
healyhatman 01 Feb, 2019
After investigation it's as I suspected - you can't get the VALUE of the calendar field on jQuery(document).ready() because it hasn't been filled at that point. It gets filled by the CF/CC form initialisation functions. You should use {var:read_data#.model.datefield} instead in your JS code to do something with the value on document.ready().
This topic is locked and no more replies can be posted.