Focal Point
Calendar Control Events

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

August 09, 2006, 04:08 PM
secret
Calendar Control Events
IN resource layout painter the calendar Control Events don't seem to work. The on change event is only executed if you manually change the text after the calendar entry is selected. What I would like to do is execute some code when the user clicks on a date. Does anyone know how to do this?

Thank you very much
August 11, 2006, 02:30 AM
<InfoSystems>
The reason the onChange event won't fire is because the Date textbox is actaully being changed by the calendar function in the WebFOCUS Client's script library.

onChange events only respond to User initiated actions and the value being added or changed by the Calendar function is technically "script initiated" not User initiated.

Note: The same thing happens for dynamic select lists populated using the Procedure or Datasource options. An associated onChange event won't fire when the User changes the dynamically populated select list because the list was originally generated by a js function in the WebFOCUS Client library.

You can get the desired behavior in both cases by writing another function that keeps track of the last value of the Date (or select list) element (using hidden elements) and constantly checks for changes. You tie the "monitor" function to an onMousemove event associated with the Body.

Any mouse movement at all triggers the "monitor" function so the values are checked frequently and will most certainly get checked immediately after the User selects the Date from the calendar (or changes the selected item) by moving the mouse.

You include an if-statement in the function that triggers the target function (the other code you want to execute) whenever the value of the calendar-controlled Date differs from the "tracking" value.

The almost constant User-initated mouse movements over the body causes the "montitor" function to check frequently, but no action triggers until an inequality is detected. The end result is the desired "onChange" behavior that you are seeking!
August 11, 2006, 05:23 AM
Tony A
Hi Bob,

The onFocus event does work with the calendar controls (despite it being created by a JS function) and I use it to tie two date controls together. I assign an attribute called dateoffset that is used in a JavaScript to work out what the date in the clicked control should be in relation to the "parent" date control -

<!-- Report Date Selection -->
<INPUT id=ITEM3 dateoffset=31 .......... etc.>
<INPUT id=ITEM4 dateoffset=1 onFocus="SetEndDate('ITEM3','ITEM4');" .......... etc.>

// This function is called when the secondary date control gets focus
// The parameters required are the parent and child date control ids
    function SetEndDate(ctrl1,ctrl2) {
// Firstly assign the control objects using the parameters
      this.BegDate = document.getElementById(ctrl1);
      this.EndDate = document.getElementById(ctrl2);
// Next set a date variable using the content of the parent date control
      var b_year = this.BegDate.value.substring(6,8);
      if (b_year<50) {b_year = eval(b_year) + 2000} else {b_year = eval(b_year) + 1900};
      var b_mnth = this.BegDate.value.substring(3,5);
      if (b_mnth<10) {b_mnth='0'+b_mnth};
      var b_date = this.BegDate.value.substring(0,2);
      if (b_date<10) {b_date='0'+b_date};
      var today = new Date(b_year, b_mnth - 1, b_date);
//alert("Date : "+today);
// The following line will ensure that all dates are an offset from the parent date correctly
// even if it does not own a dateoffset attribute.
      var offset = eval(this.EndDate.getAttribute('dateoffset')) - eval(this.BegDate.getAttribute('dateoffset'));
      today.setDate(today.getDate()-offset);
      var t_date = today.getDate();
      if (t_date<10) {t_date='0'+t_date};
      var t_mnth = today.getMonth()+1;
      if (t_mnth<10) {t_mnth='0'+t_mnth};
      var t_year = today.getFullYear();
      if (t_year>=2000) {t_year = t_year - 2000} else {t_year = t_year - 1900};
      if (t_year<10) {t_year='0'+t_year};
      var end_date = t_date+"/"+t_mnth+"/"+t_year;
      this.EndDate.value = end_date;
    }


Note that all dates used within this script are DMY format. If you require a different format then rearrange the concatenation accordingly.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 11, 2006, 09:13 AM
Tony A
For those of us on 7.1.3, there is a known problem of receiving "year is undefined" when initially clicking on the calendar image to view the calendar. No workaround is given on the tech support site.

The workaround I use is to populate the control's value with a valid date via JavaScript.

Hope this helps some of you Smiler

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
October 05, 2006, 12:17 PM
Rayden
Hi All,

I have some questions along these lines also.

I have date controls on an HTML form. When I run my fex the developer studio opens a new window about two thirds the size of a full window, when the date fields are displayed the clickable box to get the drop down for selections ends up in the middle of the field itself, also when you resize the window all the fields move but the clickable box does not. I am guessing the image is generated by some IBI javascript and it is placing the image statically on the page in specific locations, is there any way around this?

In addition when you click the image to get the pop-up calendar it always appears below and to the right of the image you are clicking, is there any way to change that too?

Any thoughts would be appreciated.

Thanks,

Rayden.


Web Focus version 7.1.4
Server Windows Server 2003
April 04, 2013, 02:00 PM
Francis Mariani
Using point-and-click in HTML Composer, I added an onFOCUS event handler function for my Calendar Control, but the event does not trigger.


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:08 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