Results 1 to 2 of 2

Thread: Help with annoying error...

  1. #1

    Thread Starter
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Help with annoying error...

    Hi evryone,

    Its been quite a while since I last used Javascript so, I'm a bit rusty

    I am using the following code here: http://s9.invisionfree.com/FS_Code_T...hp?act=Members

    I am previewing the code in IE 6.0.

    Code:
    var MemberTable = document.getElementsByTagName("table")[2];
    var MemberListTDs = MemberTable.getElementsByTagName("td");
    var PageURL = window.location.href.split("?")[0]
    for (var i = 0; i <= MemberListTDs.length; i++){
    if ((window.location.href.indexOf("act=Members") > 0) && (MemberListTDs[i].innerHTML.indexOf("showuser=") > 0)){
    var UserID = MemberListTDs[i].getElementsByTagName("a")[0].href.split("=")[1];
    var NewText = ' (<a href="' + PageURL + '?act=Msg&CODE=04&MID=' + UserID + '">PM ' + MemberListTDs[i].getElementsByTagName("a")[0].innerText + '</a>)';
    MemberListTDs[i].innerHTML += NewText;
    }}
    Now, I know the code works as it adds the text it is supposed to but I am getting an error: "MemberListTDs[i].innerHTML is null or not an object."


    Does anyone know why this error is occuring even though the code works and a way to fix this?

    Thanks for the help,

    RyanJ
    My Blog.

    Ryan Jones.

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602

    Re: Help with annoying error...

    Try changing this line:

    for (var i = 0; i <= MemberListTDs.length; i++)

    to this:

    for (var i = 0; i <= MemberListTDs.length - 1; i++)

    You might be exceeding the size of the array/collection. If that doesn't work try:

    for (var i = 1; i <= MemberListTDs.length; i++)

    I can't remember if the count starts at 0 or 1.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width