HTML/JavaScript sample

You can control TARGET Reports automation object's behavior by employing a custom user interface implemented as an HTML page. The following sample illustrates how a reporting query can be changed and final report shown in the default RTF viewer. TARGET Reports-related functionality is displayed in bold.
Please refer to the InstallDir\Samples\TARGET Reports\Automation\Web Browser folder for a complete set of files to run this sample.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Test</TITLE>
  <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <SCRIPT type="text/javascript" language="javascript" src="Base.js"></SCRIPT>
  <SCRIPT type="text/javascript" language="javascript" src="date_picker.js"></SCRIPT>
  <SCRIPT type="text/javascript" language="javascript"><!--

function Process()
{
 try {
  var rm = new ActiveXObject("Reportmanager.Reportmanager.1");
  rm.OpenProject( rm.GetStartPath() + "Samples/TARGET Reports/1.1 Summary.report" );
  var rs = rm.GetRSetup("Report_1");
  var scope = rs.GetScope()
  scope.Modify("OrderDate>='"+GetElem("cal1").value+"' AND OrderDate<='"+GetElem("cal2").value+"'")
  rm.Run(true);
 }
 catch( e ) {
  alert( "Exception:" + e.description + ", number" + e.number ); 
 }
 }

//--></SCRIPT>
 </HEAD>
 <BODY style="FONT-SIZE: 10pt">
  Order Date From: <INPUT type="text" name="cal1" id="cal1" style="WIDTH: 80px" value="01/01/1996" onkeydown="if(event.keyCode==13) return false; else if( event.keyCode == 40 &amp;&amp; window.event.altKey ) return cal1_scr.ShowCalendar(cal1_scr, event);"><a href="javascript:void(0)" onmousedown="cal1_scr.ShowCalendar( cal1_scr, event ); return true;"
   onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;"><img align="top" src="show-calendar.gif" border="0"></a>
  <DIV id="cal1_ddd" style="BORDER-RIGHT: windowframe 1px solid; BORDER-TOP: windowframe 1px solid; DISPLAY: none; Z-INDEX: 99; BORDER-LEFT: windowframe 1px solid; CURSOR: default; BORDER-BOTTOM: windowframe 1px solid; POSITION: absolute"></DIV>
  <SCRIPT type="text/javascript" language="javascript"><!--//
  cal1_scr = new CalendarScr( GetElem('cal1'), GetElem('cal1_ddd')
       );
 //--></SCRIPT>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Order Date To: <INPUT type="text" name="cal2" id="Text1" style="WIDTH: 80px" value="01/01/2000" onkeydown="if(event.keyCode==13) return false; else if( event.keyCode == 40 &amp;&amp; window.event.altKey ) return cal2_scr.ShowCalendar(cal2_scr, event);"><a href="javascript:void(0)" onmousedown="cal2_scr.ShowCalendar( cal2_scr, event ); return true;"
   onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;"><img align="top" src="show-calendar.gif" border="0"></a>
  <DIV id="cal2_ddd" style="BORDER-RIGHT: windowframe 1px solid; BORDER-TOP: windowframe 1px solid; DISPLAY: none; Z-INDEX: 99; BORDER-LEFT: windowframe 1px solid; CURSOR: default; BORDER-BOTTOM: windowframe 1px solid; POSITION: absolute"></DIV>
  <SCRIPT type="text/javascript" language="javascript"><!--//
  cal2_scr = new CalendarScr( GetElem('cal2'), GetElem('cal2_ddd')
       );
 //--></SCRIPT>
  <BR>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <INPUT type="button" value="Generate Report" onclick="Process();" ID="Button1" NAME="Button1"><BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </P>
 </BODY>
</HTML>

 

Comments