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>
Did you have a look at this post,
http://www.cognoise.com/community/index.php?topic=14852.0
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.
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
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
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.
use this ;)
<script>
checkBoxListPromptName.selectAll();
</script>