gdatetimepicker get value don't work!

pirosoft 05 May, 2017
Hi, i have two datepicker fields: id => "daterit" and "datecon".
In "datecon" i set the function "On date selected" -> controldiffdate().

The function controldiffdate is trigged, but if i try to get the value in this function of one datepicker don't go.
function controldiffdate() {
  alert(document.getElementById('datarit').value);
  alert($("#datecon").val());
}
the alert get empty response.

Why? can you help me?

thanks
GreyHead 05 May, 2017
hi pirosoft,

Please post a link to the form so I can take a quick look.

Bob
pirosoft 05 May, 2017
sure: http://www.autosystemspa.it/newrelease/index.php
GreyHead 05 May, 2017
Hi pirosoft,

I can't see how you are loading the script - if I look at the form without the template then it does not appear at all.

Do you have the script in a Load JavaScript action in the form?

Bob
pirosoft 05 May, 2017
is at the end of template:
<script>

function controldiffdate() {

alert($('#datarit').data("DateTimePicker"));
/* var ritStr = $("#datarit").gdatetimepicker.val().split('-');
var dStr = ritStr[2]+"-"+ritStr[1]+"-"+ritStr[0];
alert(dStr);
var d = new Date(dStr);
var newDStr = d.toString();
alert(newDStr);*/
}
</script>
GreyHead 05 May, 2017
Hi Pirosoft,

It looks as if it is working correctly now - maybe a cache problem??

You don't need to have that in the template and load it on every page. Please transfer the script to a Load JavaScript action in the form.

Bob
Max_admin 06 May, 2017
Hi,

The calendar element in v6 has an easy format string in the settings, I suggest that you build this form in v6 and keep your existing forms in v5

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.