Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error: "has no properties" in function

    Hello,
    I am working on a loop that counts my elements. When I debug, I get the error "e.elements[i] has no properties" (line 10).

    I have defined i as a variable with value of 0, and a form passes to e. So, I have both i and e defined as something... What's my problem? I don't understand how neither of them has properties. (Or which one, for that matter, doesn't have properties).

    PHP Code:
    function countElements(e){
    var 
    rb=0
    var b=0
    var tb=0
    var cb=0
    var i=0
    var totalNum=e.elements.length

    for(i=0;i<=totalNum;i++){
        if (
    e.elements[i].type=="text")tb=tb+1;
        else if (
    e.elements[i].type=="button")b=b+1;
        else if (
    e.elements[i].type=="radio")rb=rb+1;
        else if (
    e.elements[i].type=="checkbox")cb=cb+1

    Thanks again,
    Kristina

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when i = length, the error will occur, because the collection is zero-based, so change "i<=totalNum" to "i<totalNum"
    *this message will self destruct in n-seconds*

  • #3
    New to the CF scene
    Join Date
    Nov 2004
    Location
    Oregon
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Whoa, that was all? Thanks codegoboom!


  •  

    Posting Permissions

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