Tuesday, 2 August 2011

JavaScript to limit the number of items in multi-select Text Box Prompt - Cognos 8

<script>
var form = getFormWarpRequest();
var textBox = form._textEditBoxMarketID;
var parent=textBox.parentNode;
var select;
do {
parent= parent.parentNode;
var select= parent.getElementsByTagName("select");
} while(select.length ==0);
var opt = select[0].childNodes;
var length=opt.length

if (length > 5) // User can select maximum of 5 values from prompt.
{
alert("You have selected " + length + " O&Ds, Please select only 5 or less ");
}
</script>

In the above code, MarketID is the ID of the TextEditBox Prompt

No comments:

Post a Comment