Results 1 to 2 of 2

Thread: Function not working right in Internet Explorer only - loop and if statement

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Function not working right in Internet Explorer only - loop and if statement

    Hi,

    The following is the jist of my function:

    a call to checkString sends a string and checks it to see if it exists in an array (really an array of arrays):

    Example: var stringArray = [ ['string1', 'stringPath', 'stringText'] ]

    Then a loop goes through the array to check to see if stringArray[i][0] matches the value sent (e.g. 'string1')

    if the strings match, it should return the value of stringArray[i][1] and stringArray [i][2] (e.g. 'stringPath' and 'stringText')

    otherwise, it should return false.

    This seems to work in everything but IE. It seems that the function will return the array if the if statement is met, but it does not return anything (e.g. false) if the if statement is not met.

    however, if I hardcode the if statement to check, for example, stringArray[0][0] it works fine or even if 1==2. But obviously not what I need.

    Any ideas? Things I could look into? Thank you!

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    see if this works:
    Code:
    var stringArray = Array(Array('string1', 'stringPath', 'stringText'), Array('string2', 'stringPath2', 'stringText2'));
    function arrayVal(string) {
    for (var i=0; i<stringArray.length;i++) {
    if (stringArray[i][0]==string) {
    return Array('path'=>stringArray[i][1], 'text'=>stringArray[i][2]);
    break;
    }
    return false;
    }
    }
    so if var atts=arrayVal('string1');, atts['path']='stringPath' and atts['text']='stringText'
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

Bookmarks

Posting Permissions

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