onpropertychange在cognos新版本中不起作用

时间:2018-10-11 07:31:28

标签: javascript cognos

在cognos 10.2中,以下js脚本可很好地用于隐藏/显示功能,但是在迁移到cognos 11.0.12之后,它无法正常工作。

我替换了
node.onpropertychange=ShowOrHide;node.addEventListener("change", function(){ShowOrHide();});一起使用,它仅在我更改单选按钮值时才起作用,而不是在运行报表时起作用。

js脚本如下:

<script type="text/javascript">

try
{
  var cntlName;
  var eleTarget1 = document.getElementById('DateRadPrompt');
  var node_listDB = eleTarget1.getElementsByTagName('input');
  var eleTarget11 = document.getElementById('divGreyOut');
  var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
  if ( !fW || fW == undefined) { 
  fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}
  var list = fW._oLstChoicestodate; 


  for (var i = 0; i < node_listDB.length; i++)
  {
     var node = node_listDB[i];
     if (node.getAttribute('type') == 'radio')
     {                              
        node.addEventListener("change", function(){ShowOrHide();});                       
     }                                 
  }

  function ShowOrHide()
  {
    console.log('welcomeShowOrHide');
    var DateRadPrompt = document.getElementById('DateRadPrompt');
    var eleSource11 = event.srcElement;

    if(eleSource11.checked)
    {
      if (eleSource11.value == 'most_qtr'|| eleSource11.value == 'most_mon1'|| eleSource11.value == 'most_mon2' || eleSource11.value == 'most_mon3' ||  eleSource11.value == 'cal_prompt' ||  eleSource11.value == 'most_fsc_yr' ||  eleSource11.value == 'most_mon12' ||  eleSource11.value == 'most_qtr4' ||  eleSource11.value == 'cal_prompt1') 
     {
      eleTarget11.style.display ='none';
     } 
     else 
     {
        eleTarget11.style.display ='block';         
     }
  }
}

list.remove(1); 
list.remove(0); 
list.removeAttribute("hasLabel"); 

for (var i=0; i<=node_listDB.length;1++)
{

  var nodeDB = node_listDB[i];
  if(nodeDB.options[i].selected == true)
  {
    null
  }
  else
  {
    nodeDB.options[0].selected = true
  }

}
if (list.options.length==1) 
{
  eleTarget1.style.display='none';          
}
canSubmitPrompt();
}
catch(e)
{

}

</script>`

0 个答案:

没有答案