Focal Point
[CLOSED] Default Values for calendar control

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

February 06, 2015, 02:39 AM
info4pal
[CLOSED] Default Values for calendar control
Hi,

I have 2 calendar controls..One for start date and another for end date in the MDYY format.
Initially,both the calendar controls should be blank and only when the user clicks on them, the default value for the start date should always be the May 1st of the previous year and default value for the end date should be the sys date.

Could anyone please let me know how to do this?

Thanks a lot in advance!

Regards,
IP

This message has been edited. Last edited by: <Kathryn Henning>,


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 06, 2015, 06:26 AM
PranavJ
Hi IP,

Try this code on the 'onClick' event of calendar control, this works for me every time.

function calendar1_onclick(ctrl)
{

var NewToday = new Date();
var Today = new Date(NewToday.getFullYear(), NewToday.getMonth(), NewToday.getDate());
var DateMM = Today.getMonth() + 1;
// javascript months are 0 through 11
var DateDD = Today.getDate();
var DateYYYY = Today.getFullYear();
var DatePrevYY = DateYYYY - 1;
< !-- need 2-digit months and days and 4-digit years -->
if (DateMM < 10) DateMM = '0' + DateMM;
if (DateDD < 10) DateDD = '0' + DateDD;
document.getElementById('calendar1').value = '05' + '/01/' + DatePrevYY;
}
function calendar2_onclick(ctrl)
{
var NewToday = new Date();
var Today = new Date(NewToday.getFullYear(), NewToday.getMonth(), NewToday.getDate());
var DateMM = Today.getMonth() + 1;
// javascript months are 0 through 11
var DateDD = Today.getDate();
var DateYYYY = Today.getFullYear();

< !-- need 2-digit months and days and 4-digit years -->
if (DateMM < 10) DateMM = '0' + DateMM;
if (DateDD < 10) DateDD = '0' + DateDD;
document.getElementById('calendar2').value = DateMM +'/'+ DateDD +'/'+ DateYYYY;
}


WebFOCUS release 7.7.03, HTML, PDF, Excel
February 06, 2015, 07:21 AM
info4pal
Hi Pranav,

Thanks for the quick response but unfortunately it is throwing this javascript error message when I click on the 1st calendar control:

Line:37
Char:1
Error:'DatePrevYY' is undefined
Code :0

Please let me know!

Thanks a lot in advance!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 17, 2015, 09:06 AM
Rifaz
It won't throw JS error if you comment out unwanted lines
//Begin function calendar1_onclick
function calendar1_onclick(ctrl) {
var NewToday = new Date();
var Today = new Date(NewToday.getFullYear(), NewToday.getMonth(), NewToday.getDate());
var DateMM = Today.getMonth() + 1;
// javascript months are 0 through 11
var DateDD = Today.getDate();
var DateYYYY = Today.getFullYear();
var DatePrevYY = DateYYYY - 1;
//< !-- need 2-digit months and days and 4-digit years -->
if (DateMM < 10) DateMM = '0' + DateMM;
if (DateDD < 10) DateDD = '0' + DateDD;
document.getElementById('calendar1').value = '05' + '/01/' + DatePrevYY;
}
//End function calendar1_onclick



-Rifaz

WebFOCUS 7.7.x and 8.x
February 18, 2015, 06:26 AM
info4pal
Hi,

Rifaz - I did the same but sometimes it works and most of the times,it is throwing this error message as shown below :

Line :7
Char :764
Error:Unable to get value of the property '0'Red Facebject is null or undefined Code :0
URL:http://wfdev.corp.intranet/ibi_apps/ibi_html/javaassist/ibi/html/js/rltcale-
ndarInit.js

Thanks,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML