Focal Point
Display dynamic date value in html prompt

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

July 11, 2007, 12:46 PM
DAVID G. MASSENGALE
Display dynamic date value in html prompt
Can html painter integrate an &ervariable to
display a default value for a date prompt in
html launch page ?
July 11, 2007, 01:01 PM
Darin Lee
Couple of options: you can use a -HTMLFORM BEGIN/END in a fex (with your HTML page code in between and then any &variables you insert can become part of the launch page. This then becomes a .FEX instead of an .HTM, but it will work the same when you run it.
You can also use javascript to get a default value into a form control.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
July 11, 2007, 01:05 PM
DAVID G. MASSENGALE
Darin, thanx for the reply. I understand -htmlform begin/end and have used that technique, but I have had gui tool not open...I need to keep all within gui for client. I am js novice, can you forward sample js code ?
July 11, 2007, 01:17 PM
Darin Lee
So am I - that's why I didn't post any code. Smiler
Here's something I snipped off the internet (googled javascript get current date). You should be able to take out the pieces you need and then display the variable today as the default value in your control.

 <SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!--  Author: www.cgiscript.net  -->

<!-- Begin

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
								}

// Join it all together
today =  days[now.getDay()] + ", " +
         months[now.getMonth()] + " " +
         date + ", " +
         (fourdigits(now.getYear())) ;

// Print out the data.
document.write(today);

//  End -->
</script>
 


As I said, I know very little JS. I'm sure someone has already done this so they may have an actual example.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
July 11, 2007, 01:55 PM
DAVID G. MASSENGALE
Will try...thank you.
July 12, 2007, 02:52 AM
Tony A
David,

I use a standard module that I reference in all my WF related HTML that presets a calendar control text box with a date. The date can be "fixed" by adding an attribute of "dateoffset" to give a date relative to the system execution date.
<script>// Version 1.0
// Written by : Anthony Alsford - EDATA Limited
// Purpose    : To populate all calendar controls on a form with an elementtype attribute
//              set to "editcalendar".


// This function is called on form loading and pulls a collection of calendar controls
// before calling the function to set the date value
    function PrepDates() {
      for (i=0;i<document.all.length;i++)
      {
        if (document.all(i).elementtype == "editcalendar")
          {
           this.displayElement = document.getElementById (document.all(i).id);
           SetDate(document.all(i).id);
          }
      }
    }

// This function is designed to set the date value according to an offset value contained
// within the input tag.
// The only parameter required is the elements id value.
    function SetDate(item) {
      this.displayElement = document.getElementById(item);
      var today = new Date();
      var offset = this.displayElement.getAttribute('dateoffset');
//alert(offset);
      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();
      t_year = t_year - 2000 ;
      if (t_year<10) {t_year='0'+t_year};
      var end_date = t_date+"/"+t_mnth+"/"+t_year;
      this.displayElement.value = end_date;
    }
</script>

To include it just insert the code either via a-
<script src=filename.js></script>
or just include it within you HTML. Generally it does matter where you put the code, but as you would be calling this from your onload event you can place it inbetween the close body and close html tags.

To call it just add a line in the HTML withinin the onload script -
PrepDates();
Remember that JS is case sensitive.

Note: I do have a later version where it doesn't matter if you do not add a dateoffset attribute to your code, but I can't locate it at the moment (too many memory keys with stuff on - have to rationalise them sometime Wink)

Good luck

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