Hi folks,
I have "check box prompt" and prompt button(Next). When i click values in "check box prompt" the Next button should show and if no value checked in "checkbox prompt" the Next button should hide.
Please help me out how to achieve this using java script. I am able to done with "value prompt" and "list box prompt" but when i am using "checkbox prompt" it is not working.
Anybody have an idea how to achieve this one!!! Appriciated your help!!!
Thanks,
KS
Hi friends,
I got the solution. I will post you soon!!!
Have a nice day!!!
Regards,
SRK
I think I answered in a different place, but just so that the solution is here:
Since version 10.2 has prompt API, we can use it to achieve this.
Here's a sample. It assumes you're using a "Finish" button, change "finish" to "next" or "reprompt" where relevant.
Step 1: Name your prompt - highlight the prompt and give it a name. I used the name "CBP", if you use another name replace the word "CBP" with your name in the script below.
Step 2: Drag in one HTML Item before (To the left of) your checkbox prompt, and one HTML Item after (To the right of) your checkbox prompt. In the first one put in:
<span onclick="promptScripts.toggleButton();">
In the second one put in:
</span>
Step 3: Add a third HTML Item AFTER THE BUTTON. Add in the following script:
<script>
var promptScripts={};
promptScripts.toggleButton=function(){
var oCR=cognos.Report.getReport("_THIS_");
//get the prompt
var theCheckBoxPrompt = oCR.prompt.getControlByName("CBP");
//get the button(Change "Finish" to your type of button)
var allButtons=document.getElementsByTagName("button");
var theButton;
for(var i=0;i<allButtons.length;i++){
if(allButtons[i].name.indexOf("finish")==0){
theButton=allButtons[i];
break;
}
}
//is something selected in the checkbox prompt?
var theValues=theCheckBoxPrompt.getValues();
if(theValues.length>0){
theButton.style.display="";
}
else{
theButton.style.display="none";
}
}
promptScripts.toggleButton();
</script>
And you're basically done!
How should I modify the script if I need to disable the checkbox instead of the button?
theCheckBoxPrompt.disabled=true;
Please let me know if this is correct.