Does anyone know how to limit the number of values that can be chosen in a multi-select Select And Search Prompt in Cognos 8? Currently the options are one or unlimited, and I want to write a little Javascript that limits a certain prompt to 5 or 10 values? Does anyone know how to accomplish this?
views:
1742answers:
3
+1
A:
I'm not sure about what Cognos runs with, but here's a simple way to determine the number of selected items in a <select>
.
<script type="text/javascript">
function selCheck() {
var sel = document.form1.s1
var checked = 0
for(var x=0;x<sel.length;x++) {
if(sel[x].selected) {
checked++
}
}
alert(checked)
}
</script>
<form name="form1">
<select multiple style='width:80px;' size=5 name="s1" onclick="selCheck()">
<option>1</option>
<option>2</option>
<option>4</option>
<option>3</option>
<option>5</option>
</form>
When the user exceeds the limit you specify you would have to uncheck the last item.
Diodeus
2009-01-19 21:55:34
A:
Thanaks! This is in the direction that I need, but not quite there. I don't know how to call the selected values in a multi-select box. The multi-select "Select and Search" control in Cognos allow you to choose values from the left and "insert" them to the right. I need to count only those items that were inserted to the right. Unfortunately, Cognos doesn't provide any documentation for how to call these items from Javascript.
Any additional ideas are greately appreciated.