COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: ari_meta on 11 May 2010 04:48:12 PM

Title: Select and search prompt
Post by: ari_meta on 11 May 2010 04:48:12 PM
I have select and search prompt with multi select option. I want to limit user to select at most 10 values. How can I make it possible? Any idea plz

Thanks

Ari
Title: Re: Select and search prompt
Post by: kattaviz on 13 May 2010 10:26:45 AM
Hi,

You can do this by using javascript. I will try to post the script later.


Satish
Title: Re: Select and search prompt
Post by: ari_meta on 13 May 2010 10:42:34 AM
Thanks Satish

I was looking for same.

Ari
Title: Re: Select and search prompt
Post by: kattaviz on 13 May 2010 12:10:02 PM
Hi,

Drag an HTML Item above list box prompt and copy and paste the following javascript -

XXX is your prompt control name.

<script language="javascript">
function show() 
{
var count = 0;
var selOpts = document.forms["formWarpRequest"].elements["_oLstChoicesXXX"].options;
for(var i = 0, max = selOpts.length; i < max; ++i)
{
if(selOpts.selected)
  {
count= count+1;
  }
}
if(count>10)  // User can select maximum of 10 values from List prompt.
{
alert("You have selected " + count + " Values, Please select 10 or less values only");
}
else
       {
promptButtonFinish();
       }
}
</script>
If you are using IBM Cognos 8.3 or IBM Cognos 8.4 replace the line .

var selOpts = document.forms["formWarpRequest"].elements["_oLstChoicesXXX"].options;

with

var selOpts = getFormWarpRequest().elements["_oLstChoicesXXX"].options;

From the Toolbox, drag another HTML Item under the list box prompt and copy and paste the following code -

<button type="button" name="Validate" class="clsPromptButton"
style="font-family:Arial;font-size:10pt;font-weight :bold;width:2cm"
onClick="show()"> Finish </button>
Title: Re: Select and search prompt
Post by: ari_meta on 14 May 2010 08:06:17 AM
Thanks Satish,

I have tried this in 8.4 and 8.4.1, But it does not work, do you have any suggestion for me.

Regards

Ari

Title: Re: Select and search prompt
Post by: ari_meta on 14 May 2010 08:09:29 AM
Satish

I found this link for the same -
http://stackoverflow.com/questions/459295/cognos-javascript-how-to-limit-the-of-values-chosen-in-a-select-search-prom

Can you please help to understand this

Thanks

Ari