Want to know how to check some checkboxes by default in COGNOS? This could help your prompt page.. Get your report setup with jQuery by following this post.

On your prompt page or report, create a prompt with a checkbox. Surround it with two HTML Items, and put the following in the first:

[code]<div id="checkbox>[/code]

and the one after it should be:

[code]</div>[/code]

Place another HTML item to the right of the report title at the very top. Put your basic code in there, it should resemble something like this:

[code]<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js</a>"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {

});
</script>[/code]

Once I had this in place, I used the following JS to select the checkbox:

[code]jQuery("#checkbox input[type=checkbox]:eq(1)").attr(‘checked’,’checked’);[/code]

Let’s take a look at that particular call:

“#checkbox input[type=checkbox]:eq(1)”

This takes the checkbox div we created, and finds every input with a type attribute of checkbox. This actually returns 5 objects in my test report – an empty/hidden input, and 4 static choices I created. To select the first one, I just point to the [1] position using :eq(1). I could use 2 for the second, 3 for the third, so on.

.attr(‘checked’,’checked’);

This is jQuery’s way of saying “check this box!” All of that in one line. If you need clarification, please let me know.

(Full code)

[code]<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery("#checkbox input[type=checkbox]:eq(1)").attr(‘checked’,’checked’);
});
</script>[/code]