Focal Point
[SOLVED] JS script for fromdt and todt for Calendar

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

May 28, 2009, 11:32 AM
serenekk
[SOLVED] JS script for fromdt and todt for Calendar
This is the script I have.
I want to show todt as today date
while showing fromdt as yesterday day as (today - 1).
but somehow when clicked on the calendar icon, it goes to 2012 september? Why did not it show the defaulted date?

function window_onload() {
var today = new Date();
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<10) {t_year='0'+t_year};
var end_date = t_mnth+"/"+t_date+"/"+t_year;
var beg_date = t_mnth+"/"+(t_date-1)+"/"+t_year;
document.getElementById('TODT').value = end_date;
document.getElementById('FROMDT').value = beg_date;
UpdateData();
}

Appreciate the help!

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


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
May 28, 2009, 06:49 PM
serenekk
Any takers at all? anyone?
Maybe I need to explain a bit more to make it clear.
I have from date and to date on my HTM launch page. From Date is to be shown '05/27/2009' while To date is to show today's date, which is '05/28/2009', in MDYY format. Somehow with that script, When I clicked on the calendar Icon, it goes to weird year, August month.
How do I fix that?


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
May 28, 2009, 06:56 PM
dhagen
A) you can set the basic attributes of the calendar when you set it up. Re-edit and set the initial properties.
B) you should not try to manipulate the displayed values of html objects prior to the UpdateData() function call. WF gives you a function called "onInitialUpdate()" that it will call (if it exists) after the screen data load is done. That is where you should do your JS work.

function window_onload() {
UpdateData();
}
function onInitialUpdate() {
var today = new Date();
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<10) {t_year='0'+t_year};
var end_date = t_mnth+"/"+t_date+"/"+t_year;
var beg_date = t_mnth+"/"+(t_date-1)+"/"+t_year;
document.getElementById('TODT').value = end_date; // are the id's really TODT and FROMDT? Did you change them?
document.getElementById('FROMDT').value = beg_date;
}



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
May 28, 2009, 07:22 PM
serenekk
Thank you so much for the reply, Dhagen.
I also found another problem in my code. I forgot to change the property of the calendar into MDYY and it then worked.
thanks for the tips on where to place this java script since i am a novice in Javascript.
Thanks again!


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment