If you are unable to create a new account, please email support@bspsoftware.com

 

Selecting a value in cognos checkbox prompt using javascript in cognos10.1

Started by Bindiya, 14 Sep 2012 10:33:59 AM

Previous topic - Next topic

Bindiya

Hi All,
I am trying to use a javascript to select all the values in a checkbox prompt. I.e. Achieve the same functionality of clicking the 'select all' link under the prompt but using javascript.

Simple check box prompt with just two values. Both these values should be selected by clicking the javascript link. I used the below script. This works perfectly fine in Cognos 8.3 but is not in Cognos 10.1. Is there any alternative way to achieve the same in 10.1.

Appreciate your help.
Thanks

<script language="javascript" type="text/javascript">
function Checkall()
{
var f = getFormWarpRequest();
var c=f._oLstChoicesMycheckbox;
c[0].checked=true;
c[1].checked=true;
}
</script>

<a href='#' onClick="Checkall()"> Checkall</a>


Bindiya

Thanks for your reply.
I checked that post. He used a Cognos multiselect list box and HTML Check box prompt.
Both of them work in Cognos 10.1.

Selecting a value in Cognos multiselect list box prompt --- getFormWarpRequest()._oLstChoicesPromptName[0].selected --- works in Cognos 10.1
Selecting an option in HTML check box prompt - document.getElementById("ChkBxPromtName").checked --- works in Cognos 10.1
Selecting an option in Cognos check box prompt --- getFormWarpRequest()._oLstChoicesChkBxPromptName[0].checked --- NOT WROKING in Cognos 10.1

This is the issue. May be I should remove this javascript and look for some workaround.

RKMI

Yes, I think you are correct you need a work around without the javascript.

By creating one static choice for 'ALL' and select choices by [FieldName] in use value for followed writing some form of case statement  in main query.
CASE
WHEN (#prompt('Select FieldName','Char')# = 'ALL') THEN (1=1)
ELSE [FieldName] = [FieldName]
END

Thanks,
RK

pricter

I tried the following in 10.1.1

<script type="text/javascript">
function Checkall()
{
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
fW._oLstChoicesPromptName.options[0].selected = true;
fW._oLstChoicesPromptName.options[1].selected = true;
canSubmitPrompt();
}

</script>


and it worked.

You could give it a try

Bindiya

Looks like you tried this on a multiselect list box prompt (correct me if I am wrong). In which case it could work perfectly fine. I want to make it work on a check box prompt.

afzaki7

use this  ;)


<script>
checkBoxListPromptName.selectAll();
</script>
" إِذَا مَاتَ ابْنُ آدَمَ انْقَطَعَ عَمَلُهُ إِلا مِنْ ثَلاثٍ : مِنْ صَدَقَةٍ جَارِيَةٍ ، أَوْ عِلْمٍ يُنْتَفَعُ بِهِ ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ "