Step 5 Add the Calendar Control and Edit the Default JavaScript

LANSA Web Functions

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.

  

<tr>

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

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

<RDML MERGE="STD_DATE  " EDITCODEI="Y">

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

<td>

<a href="javascript:CallCalendar()"><img src="/IMAGES/TB_CAL.GIF" alt="Calendar" border="0" width="70" height="21" hspace="0" vspace="0" align="left" /></a>

</td>

</tr>

</tbody>

</table>

 

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:

  

<RDML ONCONDITION="USECALENDAR">

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 = window.open("/images/lcalen.htm", "calendar", opt)

      win.opener=window

   }

}

function SetDate(day, month, year)

{

   var Field=document.LANSA._CALFLD.value;

 

 

   if (day < 10)

        day="0"+day;

   if (month < 10)

        month="0"+month;

   if (year < 2000)

        YearRet=year-1900;

   else

        YearRet=year-2000;

 

   if (YearRet < 10)

        YearRet="0"+YearRet;

 

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

 

   var NumElements=document.LANSA.elements.length;

 

 

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

   {

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

      {

         document.LANSA.elements[i].value=Rdate;

         break;

      }

   }

}

</RDML>

 

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;

to

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

  

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