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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Javascript complains of null object

Started by cognosfreelancer, 06 Aug 2007 04:28:42 PM

Previous topic - Next topic

cognosfreelancer

Folks

I use javascript in an HTML element located in the report page to refer to a prompt located in the Prompt page.

The prompt I am referring to is a single select List box with the name of 'divIDCustNamePrompt'.

In my HTML element I have a JS function as well as code that exists outside of the function.

This HTML element is placed at the bottom of the report page.

The following is the Javascript code in the HTML element:

----------------------------------------------------------------

<script language="javaScript">

   var val="";
    var theone;
   try{ 

  var els = document.forms["formWarpRequest"].elements["_oLstChoicesdivIDCustNamePrompt"];   

      for (i=0; i < document.forms["formWarpRequest"].elements["_oLstChoicesdivIDCustNamePrompt"].length; i++)
   {   
      if (document.forms["formWarpRequest"].elements["_oLstChoicesdivIDCustNamePrompt"].options.selected)
      {   
         theone=i;
         val = document.forms["formWarpRequest"].elements["_oLstChoicesdivIDCustNamePrompt"].value;
         alert("Selected #" + theone + " Value= " +val);
               }
   }

}
catch(err)
   {
   txt="There was an error on this page.\n\n"
   txt+="Error description: " + err.description + "\n\n"
   txt+="Click OK to continue.\n\n"
   alert(txt)
   }

   //This function obtains the value of the selected Division ID and Customer Name
function getDivIDCustName(){
          document.forms["invokeJSP"].elements["divIDCustName"].value=val;

}

</script>

---------------------------------------------------------------------------------------

When I run the report and get to the report page after entering the values for the prompt I get the following error message:

'_oLstChoicesdivIDCustNamePrompt.length' is null or not an object.


What am I missing

Thanks

NKT

cognosfreelancer

For the benefit of those interested in my resolution of this problem.

Cognos 8 uses the same form name in multiple pages viz. 'formWarpRequest' leading to some confusion atleast to me.

The form elements that I wanted to access were located on the prompt page whereas my Javascript code was located on the report page for reasons that are not relevant to this discussion.

It is not possible to reference prompts located in a differnent document than the one in which the JS code is located. I tried using the 'window' object in the HMTL DOM object model in vain.

NKT