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

html javascript error for prompt button

Started by pcog, 10 Feb 2012 04:14:41 PM

Previous topic - Next topic

pcog

Hi gurus,

I'm using a javascript for prompt button. I would have use cognos prompt button but, script has some alert messages to show when user entering the prompts.
When I hit the prompt button it is giving error as 'null' is null or not an object. Please find the attached snapshot of the error.
I used to have 2 date ranges prompts before and this button was working fine. Later we don't require the second date range so we deleted that prompt and modified script accordingly. Since then I'm getting this error.

Please help me out. here is the script.
Thanks in advance

<script language="javascript">

function checkSaSSelected ( SaSName ) 
{
  var vDivWrapper = document.getElementById(SaSName);
  var vSelectArray = vDivWrapper.getElementsByTagName("select");
  var vSelect = vSelectArray[0];
  var vOptionsArray = vSelect.getElementsByTagName("option");
  var vSelected = false;
  for ( i = 0; i < vOptionsArray.length; i++ )
  {
    if ( vOptionsArray.selected == true ) { vSelected = true }
  }
  return vSelected;
}

function getVPValue ( vpName )
{
  var vWrapper = document.getElementById(vpName);
  var vDivArray = vWrapper.getElementsByTagName("div");
  var vInputArray = vDivArray[1].getElementsByTagName("input");
  var vReturnValue;
  for ( i = 0; i < vInputArray.length; i++ )
  {
    if ( vInputArray.selected ) { vReturnValue = vInputArray.value; }
  }
  return vReturnValue;
}

function getDateValue ( dtName )
{
  var vDivWrapper = document.getElementById(dtName);
  var vSelectArray = vDivWrapper.getElementsByTagName("select");
  var vSelect = vSelectArray[0];
  var vOptionsArray = vSelect.getElementsByTagName("option");
  var vSelected = false;
  for ( i = 0; i < vOptionsArray.length; i++ )
  {
    if ( vOptionsArray.selected == true ) { vSelected = vOptionsArray.value }
  }
  return vSelected;
}

function validate (  ) 
{
  var vType = getVPValue("AcctTypeVP");
  var vDteRng1Start = null;
  var vDteRng1End = null;

  vDteRng1Start = getDateValue("Rng1Start");
  vDteRng1End = getDateValue("Rng1End");

// - use for seeing actual values passed during modifications of code
//{ alert (vType ); }
//{ alert ( vDteRng1Start); }
//{ alert ( vDteRng1End); }

   if ( (vType == "Consolidate" && checkSaSSelected('AcctSaST1') ) || ( vType == "Individual" && checkSaSSelected('AcctSaST1WithT2') )
         || ( vType == "Detail" && checkSaSSelected('AcctSaST2'))
         &&
         (!(vDteRng1Start==null||vDteRng1Start=="null") && !(vDteRng1End==null||vDteRng1End=="null"))
         &&
         (vDteRng1Start < vDteRng1End)
      )
    { promptButtonFinish(); }
  else if  (vType == "Consolidate" && (checkSaSSelected('AcctSaST1') != true))
    { alert ( "A T1 Account number is required!" ); }
  else if  ( vType == "Individual" && (checkSaSSelected('AcctSaST1WithT2') != true))
    { alert ( "A T1 Account number is required!" ); }
  else if  ( vType == "Detail" && (checkSaSSelected('AcctSaST2') != true))
    { alert ( "A T1 Account number is required!" ); }
  else if (vDteRng1Start == null||vDteRng1Start == "null")
    { alert ( "Dates are required fields. A starting date for the first date range is required!" ); }
  else if (vDteRng1End == null||vDteRng1End == "null")
    { alert ( "Dates are required fields. An End date for the first date range is required!" ); }
  else if (vDteRng1Start > vDteRng1End)
    { alert ( "The starting date in a date range cannot be later then the end date!" ); }
  else
    { alert ( "Required Fields have not been updated" ); }
}

</script>

<button type="button" name="Validate" class="clsButton"
style="font-family:Arial;font-size:10pt;width:2cm;height:30px"
onClick="validate()">Submit</button>