COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: avuong6 on 01 Nov 2017 03:46:12 PM

Title: javascript to hide element
Post by: avuong6 on 01 Nov 2017 03:46:12 PM
i have a prompt page where i would like to use the selection of a value prompt to hide or unhide another value prompt further down on page.
how to do with javascript and prompt api in 10.2.2?

i have this code:
======================================================
<script language="javascript">
function ShowHide2(){

var el = document.getElementById("OtherOps7");
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
                     }
}

function startHidden2(){
var el = document.getElementById("OtherOps7");
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
}

window.onload=startHidden2();

</script>
======================================================

it works when i call the function from a javascript link. however i want to call it based on the value of the prompt. when the dropdown has 1, it should hide, and when dropdown has 2, it should show.





Title: Re: javascript to hide element
Post by: Kiran Kandavalli on 13 Nov 2017 12:34:02 PM
Hope my understanding is correct,

You want to hide ValuePrompt2 based on ValuePrompt1 right?, if yes, we can use a Render Variable to hide the ValuePrompt2.

Steps:

1) Create ValuePrompt1 and enter Static Choices as 1 & 2
2) Select the Default Value as "1"
3) in ValuePormp1 change AutoSubmit Property to "Yes"
4) Create Value Prompt2 and in Properties select the Cascading source as "Parameter of ValuePrompt1"
5) Create a Variable
     Case
     when ParamValue(?Parameter of ValuePrompt1?)=1 then ('S')
     else ('DS')
     End
6) in Value Prompt2 Properties - Render Variable --> Select this Variable and select the option 'S'
7) Run the Report.

Thanks!
Kiran