Hello,
It is strange for me, but I can't dynamically disable the "PROMPTBUTTON_NEXT" or "PROMPTBUTTON_FINISH", and I mean I still don't know how. Maybe someone has the solution (?)...
I tried to make a short copy of some code found in .JS in Cognos repository, like that for example:
function EnableButton(var_enabled)
{
if (pageNavigationObserverArray)
{
var kCount = pageNavigationObserverArray.length;
for (var j=0; j<kCount; j++)
{
var promptElement = eval(pageNavigationObserverArray[j]);
var promptElementType = promptElement.getType();
if (promptElementType == PROMPTBUTTON_NEXT || promptElementType == PROMPTBUTTON_FINISH)
{
promptElement.setEnabled(var_enabled);
break;
}
}
}
}
In fact, it's working but as soon as there's a change in a promptElement, Cognos is checking the values in these elements and in our case ( as the listBox has a SelectedIndex > -1 ) Cognos considers that the report can run -> so the finishButton is enabled again ! (after the short code above is executed)
I don't know how to manage to put some "Flag", or "By pass" this event.
If anyone else knows, It could be very interesting.
The last solution is catching the "onclick" event on the listBox, and automatically deselect an item as soon as there are more than 2 items selected:
HTML Item1
<script text=javascript>
var Lbox = document.forms["formWarpRequest"].elements["_oLstChoiceslstJS"];
Lbox.attachEvent("onclick", m_click);
</script>
HTML Item2
<script text=javascript>
function m_click()
{
var n_count = 0;
for (var i = 0; i < Lbox.length; i++)
{
if (Lbox[i].selected)
{
n_count++;
}
}
if (n_count > 2)
{
Lbox.options[Lbox.options.selectedIndex].selected = false;
}
}
</script>
So, now, you can't select more than 2 items in the list.
But you will surely see that it is not perfect:
-> if you select the items (multiselect of course) from the last Item in the list to the first (from the bottom to the top of the list), the code will deselect the last clicked Item and that point is OK.
-> if you do this from the first to last item, the code will deselect the previous selected Item.
I don't know why, I've never seen this with C++Builder or Delphi objects, sorry.