COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Bindiya on 14 Sep 2012 10:33:59 AM

Title: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: Bindiya on 14 Sep 2012 10:33:59 AM
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>
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: RKMI on 14 Sep 2012 06:02:29 PM
Did you have a look at this post,

http://www.cognoise.com/community/index.php?topic=14852.0
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: Bindiya on 17 Sep 2012 12:54:29 PM
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.
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: RKMI on 17 Sep 2012 01:35:39 PM
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
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: pricter on 17 Sep 2012 01:43:39 PM
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
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: Bindiya on 17 Sep 2012 03:02:09 PM
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.
Title: Re: Selecting a value in cognos checkbox prompt using javascript in cognos10.1
Post by: afzaki7 on 16 Feb 2016 04:17:46 AM
use this  ;)


<script>
checkBoxListPromptName.selectAll();
</script>