Forums

[BUG?] Calendar field don't fill when event onchange is trigger

senmadrid 02 Apr, 2020
Hi

Im trying create a event in javascript to calcule age with birthdate



I add a custom/javascript module in form with this code:
​[pre]function calculateage()
{[br] var fecha=document.getElementById("fecha_de_nacimiento").value;[br] var justnow=document.getElementById("nowdate").value;[br] alert("birthdate: "+ fecha+ " Now: "+justnow);[br] [br]}[br][/pre][br]

The problem is when i try pick a date in "fecha_de_nacimiento" the event trigger but don't write nothing in field "fecha_de_nacimiento" and then i can't calculate age in function :/





Im doing something wrong?
Max_admin 06 Apr, 2020
without this event it works ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
healyhatman 06 Apr, 2020
You might need to apply an onchange event directly in JS to the hidden field that's under the calendar that actually holds the selected date.
senmadrid 07 Apr, 2020

without this event it works ?


Yes, the event work fine, the problem is the calendar, when i choose the date, first launch event onchange and later fill the field with the date.. (click on field - calendar poppup - choose date and click - event onchange launch - event onchange finish - calendar fill field with data) then i can't pass the value fill to the date, maybe can i pass the value calendar to event? how?

You might need to apply an onchange event directly in JS to the hidden
field that's under the calendar that actually holds the selected date.


I don't know what you want say (sorry my english is no very good)

the hidden field is date nowdate, this load on load document, can't fire onchange because no change

I try apply the onchange event in the field "Age" where show the results of event, and work fine, but no its a soluction, because you need write anything here to launch the event

The problem is the calendar i thik, if the field is writeen before event is launch then will work as expected, or maybe a way to capture the calendar data on onchange launch
senmadrid 07 Apr, 2020
without js script the calendar work fine
Max_admin 11 Apr, 2020
Just try to call $("#nowdate").val("2020") in the code, does it set the field value ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
senmadrid 21 Apr, 2020
what? the problem is get the birthdate data (fecha_de_nacimiento) i havent any problem with nowdate

The real problem is that the event "on change" from javascript is trigered after the value of calendar is set in the field, then i can't get it in the event.
Max_admin 23 Apr, 2020
Could you please download v7 beta and try this ? it should work fine, and actually there is a "Set Value" action that you can use directly!
http://www.chronoengine.com/blog
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.