SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Incrementing a Object Name

    I just need to get a unique number dynamically at the end of the new object name (paItem) name but I get an error when i try to do it this way. Please Help!

    for (i=0; i<table.length; i++)
    {
    paItem[i] = new paOrgValues(vName, vQty, vPrice, vTot, vSelRad);
    }

    Thanks a bunch!

    jfyounce

    P.S. There is one table so the [i] should turn into a zero.

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's array syntax. Using it like that is not what you want.

    Code:
    this['paItem'+i]  // it it's a local variable
    window['paItem'+i]  // it it's a global variable
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •