Step 5. Add the Calendar Control and Edit the Default JavaScript

In this step, you will enable and test the calendar control JavaScript function. You will also change the date format used in the JavaScript from MM/DD/YY to DD/MM/YY.

1.  Open the iiiPR0C03 iiiFN05001 page and insert the bolded lines which will include a Calendar button beside the #STD_DATE field.



<td><strong><RDML MERGE="@T0002+0021+0040"></strong></td>

<td><input name="SSTD_DATE " type="text" maxlength="008" align="right"


onfocus="SetNameLocation('SSTD_DATE ',04,29)"></td>


<a href=".././index.htm" target="_blank"="/IMAGES/TB_CAL.GIF" alt="Calendar" border="0" width="70" height="21" hspace="0" vspace="0" align="left" /></a>






2.  Save the document.

3.  Open the default JavaScript page called DEFAULT_SCRIPT.

4.  Remove the conditions on the JavaScript for the Calendar functions by deleting the two bolded lines in the following code:



function CallCalendar()


   if (document.LANSA._CALFLD.value != "&NULL")


      var opt = "width=340,height=385,directories=no,toolbar=no,"

      opt += "menubar=no,scrollbars=no,resizable=yes"

      win ="/images/lcalen.htm", "calendar", opt)




function SetDate(day, month, year)


   var Field=document.LANSA._CALFLD.value;



   if (day < 10)


   if (month < 10)


   if (year < 2000)





   if (YearRet < 10)



   var RDate=day+"/"+month+"/"+YearRet;


   var NumElements=document.LANSA.elements.length;



   for (i=0; i<NumElements;i++)


      if (document.LANSA.elements[i].name==Field)









5.  Next, modify the script so that the calendar control returns the date in format MM/DD/YY by changing the statement:

var RDate=day+"/"+month+"/"+YearRet;


var RDate=month+"/"+day+"/"+YearRet;


6.  Use the Save As option to save the document as:     iiiPROC03_SCRIPT