COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Topic started by: crossjoin on 11 Dec 2007 04:19:30 AM

Title: [Solved] forcing selection in one of several optional prompts
Post by: crossjoin on 11 Dec 2007 04:19:30 AM
Hi,

I'm supposed to come up with a solution to a problem that involves forcing users to select a value in one of three ways:

One and only one of the three options must be used. Is there any way to force selection for a group of prompts that are individually optional prompts? So the group acts as a logical mandatory prompt, but it's members are optional. The solution should preferably work without altering the cognos javascript include files that reside on the server. If there is a solution does it work for Cognos8, ReportNet 1.x or both?

regards,
crossjoin
Title: Re: forcing selection in one of several optional prompts
Post by: almeids on 11 Dec 2007 12:52:52 PM
I think you would need to implement this as a Javascript validation, wired into the Finish button on your prompt page.  I haven't done any of this myself but from what I've read it's possible (should be so in both environments).  Try searching this and other forums for "date validation", validating end-date-greater-than-start-date seems to come up a lot and might give you some ideas for the approach, though not the specifics of the code.
Title: Re: forcing selection in one of several optional prompts
Post by: crossjoin on 13 Dec 2007 01:42:35 AM
Thanks for trying to help, almeids  :)
You didn't actually point out anything new to me, but the effort is appreciated regardless.

However, I have found something that seems to work with a custom Finish button.

<script>
function customCheckPage(){

    var parcount = 0;

     if (document.getElementById("_textEditBoxtxtAct").value.length > 0) {
          parcount = parcount + 1;
     }

     if (document.getElementById("_oLstChoicescboAct").value.length > 0) {
          parcount = parcount + 1;
     }

     if (document.getElementById("_sws_myparam_search_selectChoicessspAct").value.length > 0) {
          parcount = parcount + 1;
     }

     if (parcount == 1) {
          promptButtonFinish();
     }
     else if (parcount == 0) {
          alert("You have not selected a value!\n Select a value in one of the prompts.");
     }
     else {
          alert("You used more than one prompt!\n Please use only one prompt.");
     }
}
</script>

<button onclick="customCheckPage()" 
        style=""
        class="clsPromptButton"
        onmouseover="this.className = 'clsPromptButtonOver'"
        onmouseout="this.className = 'clsPromptButton'">Finish</button>


What would be nice is to disable the Finish button and only show it when in only one prompt a value is selected. Maybe trapping click and keypress events can help out to achieve that.