You are on page 1of 5

Tip or Technique

Hide In-Body Prompts


Product(s): Cognos 8, Cognos ReportNet
Area of Interest: Report Design
Hide In-Body Prompts 2

Copyright
Your use of this document is subject to the Terms of Use governing the
Cognos software products and related services which you have licensed or
purchased from Cognos. The information contained in this document is
proprietary information of Cognos Incorporated and/or its licensors and is
protected under copyright and other applicable laws. You may use the
information and methodologies described in this document 'as is' or you may
modify them, however Cognos will not be responsible for any deficiencies or
errors that result from modifications which you make. Copyright 2006 (c)
Cognos Incorporated. All Rights Reserved.
You can print selected pages, a section, or the whole book. Cognos grants
you a non-exclusive, non-transferable license to use, copy, and reproduce the
copyright materials, in printed or electronic format, solely for the purpose of
providing internal training on, operating, and maintaining the Cognos
software.
This document is maintained by the Best Practices, Product and Technology
team. You can send comments, suggestions, and additions to Best Practices,
Product and Technologies.

Cognos Proprietary Information


Hide In-Body Prompts 3

Contents
1 INTRODUCTION ............................................................................................ 4
1.1 PURPOSE .............................................................................................................. 4
1.2 APPLICABILITY ....................................................................................................... 4
1.3 EXCLUSIONS AND EXCEPTIONS .................................................................................... 4
2 HOW TO USE IT............................................................................................. 4
3 ATTACHMENTS .............................................................................................. 5

Cognos Proprietary Information


Hide In-Body Prompts 4

1 Introduction
1.1 Purpose
This is a technique that allows you to hide in-body prompts on an HTML
report to save space. The report output displays with a link to ‘Change Report
Filters’. When the user clicks on this link, the in-body prompts appear. If the
user changes the prompts and re-submits the report, the prompts are hidden
by default when the report is rerun. If the user decides to not change the
filters, they can re-hide the prompts by clicking on the link provided.

1.2 Applicability
The script was written in Cognos 8.1.108 MR1 and was successfully tested in
IE 6.0, Netscape 7.2 & 8.1 and Mozilla Firefox 1.0.4.

1.3 Exclusions and Exceptions


The following assumes that the prompt(s), associated labels and any re-
submit button (if necessary) are placed inside of some container, such as a
block or a table. This is not a requirement; it just makes it easier to place the
beginning and ending HTML Items on the report.
This code uses named items that are not part of the existing report
specification, so there shouldn’t be any need to update the code due to an
upgrade, but there is no guarantee. This same code can be used to
hide/show and other items within HTML report output.
Also Note that the technique described below does not leverage functionality
specific to Cognos products. This technique relies entirely on the ability of the
browser to interpret and process JavaScript for HTML document
manipulation. The script operates by modifying the style of a div block to
alternately display or hide (default) the contents of the HTML div block.

2 How to use it
Place an HTML Item directly before the prompt area container (block or
table) or directly before the first prompt item you would like to hide in the
report layout.
Place the following code within that HTML Item:

<script language="JavaScript">
//<!--
var g_NavOpen = 0;
function togglePromptDiv(){
if (g_NavOpen){

document.getElementById('divPromptArea').style.display="none";
document.getElementById('anchorHideShow').innerHTML="Show
Filter Prompt(s)";
g_NavOpen = 0;}
else{
document.getElementById('divPromptArea').style.display="";

Cognos Proprietary Information


Hide In-Body Prompts 5

document.getElementById('anchorHideShow').innerHTML="Hide
Filter Prompt(s)";
g_NavOpen = 1;}
}
//-->
</script>
<a href="javascript:togglePromptDiv()" border="0"
id="anchorHideShow">Show Filter Prompt(s)</a>
<div id="divPromptArea" style="display:none">

Place a second HTML Item directly after the prompt area container (block or
table) or directly after the last prompt item you would like to hide in the
report layout.
Place the following code within that HTML Item:

</div>

When you run the report, the prompt area will be hidden by default. Click on
the ‘Show Filter Prompt(s)’ link to view the prompt area. You can then answer
prompts and rerun the report or click the ‘Hide Filter Prompt(s)’ link to hide
the prompt area.

3 Attachments
The attached sample uses the ‘GO Sales and Retailers’ package.

Cognos Proprietary Information

You might also like