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
Hi,
You can do this by using javascript. I will try to post the script later.
Satish
Thanks Satish
I was looking for same.
Ari
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>
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
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