Javascript Help!

Discussion in 'OT Technology' started by z06, Oct 29, 2004.

  1. z06

    z06 New Member

    Joined:
    May 27, 2003
    Messages:
    141
    Likes Received:
    0
    I having this error and I have no idea how to fix it, so if someone could look at my code and help me out I would greatly appreciate it.

    It tells me that I have an 'undefined' is null or not an object error.

    Code:
    function beale2()
    {			
    var strDI=" ,"+document.dform.di.value;
    var aryDI=strDI.split(',');
    var strSecret=document.dform.secret.value;
    
    if (strSecret.charAt(0)!=",")
    {
    	strSecret=" ,"+strSecret;
    }
    
    var arySecret=strSecret.split(',');
    var strMsg="";
    
    for (i=1; i<arySecret.length; i++)
    {
    	strMsg=strMsg+aryDI[arySecret[i]].charAt(0); <-- this is the line where the error occurs
    }
    
    document.dform.answer.value=strMsg;
    }
    
    Thanks in advance!
     
  2. Jaycee0521

    Jaycee0521 New Member

    Joined:
    Jul 15, 2004
    Messages:
    64
    Likes Received:
    0
    trace it... do an alert or something so youll know which one is null...

    after you split arySecret and aryDI try doing this...

    for(i=0;i<arySecret.size();i++)
    {
    alert(arySecret);
    }

    then do it for the other array... if it has an error or a null value at the first one or if it gives the same error... check further up... look for the point where it became null...

    var strDI=" ,"+document.dform.di.value;
    var aryDI=strDI.split(',');
    var strSecret=document.dform.secret.value;

    document.dform.*.value may have had problems...
     

Share This Page