Focal Point
[CLOSED] Calendar onChange event

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1037003395

November 08, 2010, 11:55 AM
Suzy
[CLOSED] Calendar onChange event
The calendar onChange event only seems to work when the user manually enters the date, not when they click on the icon and select a date.

Below is the javascript. Is there a workaround for this?

  
 function ddlStartEndTime_onchange(ctrl) {
 
 if (FromDate.value == ToDate.value){
 pnlStartEndTime.style.visibility = 'visible';
 gbDate.style.height = '150px';
 pnlOptional.style.top = '190px';
 }
 else
 {
 pnlStartEndTime.style.visibility = 'hidden';
 pnlOptional.style.top = '170px';
 gbDate.style.height = '120px';
 
 }
 }



Below is the HTML calendar inputs.

  

<INPUT id=FromDate title=!IBI.AMP.DATE_FORMAT_LBL; style="FONT-SIZE: 8pt;
 Z-INDEX: 8; LEFT: 220px; WIDTH: 80px; FONT-FAMILY: Arial; POSITION: absolute;
 TOP: 0px; HEIGHT: 20px" tabIndex=3 onFocus=ddlStartEndTime_onchange(this);
 size=5 name=FromDate operation="NONE" cacheruntimedata="0" elementtype="14"
 ibiformat="MDYY" calendardatatype="1" calendardata="0/0/-5;0/0/2">
 
 <INPUT id=ToDate title=!IBI.AMP.DATE_FORMAT_LBL; style="FONT-SIZE: 8pt; Z-INDEX:
 10; LEFT: 360px; WIDTH: 80px; FONT-FAMILY: Arial; POSITION: absolute; TOP: 0px;
 HEIGHT: 20px" tabIndex=4 onFocus=ddlStartEndTime_onchange(this); size=18
 name=ToDate operation="NONE" cacheruntimedata="0" elementtype="14"
 ibiformat="MDYY" calendardatatype="1" calendardata="0/0/-5;0/0/2"></SPAN>

This message has been edited. Last edited by: Kerry,


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
November 08, 2010, 02:23 PM
Prarie
What happens when they click on the dates? Do they get an error? If so...what is it.
November 08, 2010, 02:26 PM
Suzy
Nothing happens, the onChange event doesn't get called.


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
November 09, 2010, 03:48 AM
Wep5622
Yeah, the date control doesn't seem to be quite complete and apparently contains a bug where it doesn't always apply the "right" date-formatting before posting it. Which brings me to the issue that there doesn't seem to be a way to specify what date-format it should be using at all, that's bound to cause problems sooner or later.
I don't know who implemented that control, but it almost seems like they stopped working on it half-way through...

I usually include below javascript for HTML forms that make use of the calendar control.
It overrides one of IBI's functions to change its behaviour. You may not need all of it, it's not entirely clean; I rolled my own event-attach function - there's probably one in the IBI code-base, but I didn't bother searching for it.

Still, it would be better if we'd get a complete implementation that handles

Right now we have to "parse" the posted date, as it can be in either of two formats!

// Event handler to add rawvalue after calendar field was changed by hand
function calendarChanged(obj, event) {
	obj.setAttribute("rawvalue", obj.value);
}

/*
 * Override WebFOCUS version with one adding an onchange event handler
 */
function setupDocCalendars()
{
	var coll = document.getElementsByTagName("INPUT");
	for( var i = 0; i < coll.length ; ++i )
	{
		oCtrl = coll[i];
		if(oCtrl.getAttribute("elementtype") != 14) continue;
		var ibiFormat = _getCalendarProperty(oCtrl, "ibiformat");
		if( isATextControl(oCtrl) &&
			0 == oCtrl.readOnly &&
			'none' != oCtrl.style.display &&
			'hidden' != oCtrl.style.visibility &&
			ibiFormat != null &&
			isYMDCombo(ibiFormat)
		) {
			setupCtrlCalendar( oCtrl, ibiFormat);
			addEventHandler(oCtrl, "change", calendarChanged);
		}
	}
	return;
}

function addEventHandler(obj, eventType, callback) {
	if (obj.addEventListener) {
		obj.addEventListener(
			eventType,
			function() { callback(obj, eventType); },
			false
		);
	} else if (obj.attachEvent) {
		obj.attachEvent(
			'on' + eventType,
			function() { callback(obj, eventType); }
		);
	}
}



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
November 09, 2010, 09:50 AM
dhagen
Your onchange function is attached to the onFocus event .... you might want to mess with that a bit.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
November 23, 2010, 11:35 AM
Suzy
Adding an onmousemove event to the BODY fixed this.


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
April 04, 2013, 01:01 PM
Francis Mariani
Hmmm, added the onmousemove event to the body tag, via point-and-click. The function called in this event function has an alert. As soon as I added the onmousemove event, I got an endless loop of alert - had to use Windows Task Manager to kill Dev Studio.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 05, 2013, 02:10 PM
Francis Mariani
It looks like the following works in versions prior to v8:

Put the Calendar Control in a container and add an onmouseover event handler to the container.

I added the onmouseover event handler to the gold (Salmon?) panel.




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server