How to: |
You can use a StyleSheet to define a link to a JavaScript function from any report component. After you have defined the link, you can select the report component to execute the JavaScript function.
Just as with drill-down links to procedures and URLs, you can specify optional parameters that allow values of a report component to be passed to the JavaScript function. The function will use the passed value to dynamically determine the results that are returned to the browser. For details, see Creating Parameters.
Note:
TYPE=type, [subtype], JAVASCRIPT=function[(parameters ...)], $
where:
The maximum length of a JAVASCRIPT=function argument, including any associated parameters, is 2400 characters and can span more than one line. If you split a single argument across a line, you need to use the \ character at the end of the first line, as continuation syntax. If you split an argument at a point where a space is required as a delimiter, the space must be before the \ character or be the first character on the next line. The \ character does not act as the delimiter.
In this example,
JAVASCRIPT=myfunc(COUNTRY \ CAR MODEL 'ABC'),$
the argument correctly spans two lines.
Note:
For more information about the -HTMLFORM command, see the TIBCO WebFOCUS® Developing Reporting Applications manual.
The following displays the report and StyleSheet syntax used to link to a JavaScript function. It also shows the JavaScript function that is executed, and the result that is displayed in the browser.
The report request (which contains the inline StyleSheet) is:
TABLE FILE GGORDER SUM PRODUCT_ID BY STORE_CODE BY PRODUCT_DESCRIPTION NOPRINT IF STORE_CODE EQ 'R1250' ON TABLE HOLD AS JAVATEMP FORMAT HTMTABLE ON TABLE SET PAGE-NUM OFF ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, $ TYPE=DATA, COLUMN=PRODUCT_ID, JAVASCRIPT=showitem(PRODUCT),$ ENDSTYLE END -RUN -HTMLFORM JAVAFORM
The JAVAFORM.HTM file that contains the JavaScript function is:
<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> // This function will display the value in the text box function showitem(string) { document.form1.text1.value = string; } // End the hiding here </SCRIPT> </HEAD> <BODY> !IBI.FIL.JAVATEMP; <HR> <B>Product Description:</B> <FORM NAME="form1"> <INPUT TYPE="text" NAME="text1" SIZE="16"> </FORM> </BODY> </HTML>
When you execute the report procedure, the following report displays in the web browser. If you select a Product Code link, the JavaScript function ShowItem executes, and displays the value of the PRODUCT_DESCRIPTION field (a NOPRINT field) in the text box in the form below the report. For example, if you select the Product Code G104, "Thermos" displays in the Product Description field.