COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Cognos10x on 09 Aug 2016 03:15:51 PM

Title: Java Script to show and hide report object on Prompt page
Post by: Cognos10x on 09 Aug 2016 03:15:51 PM
 I need to show and hide the optional prompts on the prompt page. Can please help with the Java script.
I found a Java Script which can do that but couldn't figure out how to hide the report object/prompt by default on the page load. I have attached the .xml page for your reference.
Title: Re: Java Script to show and hide report object on Prompt page
Post by: AnalyticsWithJay on 10 Aug 2016 07:09:30 AM
I didn't load your report specs, but to hide it on load you can do the following:

Place an HTML item to the left of it with the code:
<div id="myFirstPrompt" style="display: none; visibility: hidden;">

... Your Prompt Here ... After the prompt, place the following code in an HTML item:

</div>

Your JS code will reference the ID of an element to make it visible. Make sure you change the ID of "myFirstPrompt" to whatever you want. Also note that IDs must be unique, so if you have more than one prompt you want hidden, choose different names.

Obligatory disclaimer: JS code can break reports during future upgrades. Use it with caution.
Title: Re: Java Script to show and hide report object on Prompt page
Post by: dougp on 10 Aug 2016 10:31:18 AM
I'd love to help, but I couldn't load your report spec.

What version of Cognos are you using?
Is the sample code using the Samples that came with Cognos?  (Great Outdoors)
Can you please describe your requirements?  (What is the expected user behavior or condition that hides or shows optional prompts?)

You shouldn't need to use JavaScript to do this.  It can be done with parameters and conditional rendering.  That should survive an upgrade.