Results 1 to 4 of 4
  1.    #1  

    im trying to combine to arrays to one, where values may differ.
    For example:

    items[0].tag = "tag1"
    items[0].source = "user"

    other[23].tag = "tag1"
    other[23].checked = "true"

    So you see, the TAG-value is the same, i have absolutly no idea how to build a fast (!!) method with prototype to get an array like this:

    items[0].tag = "tag1"
    items[0].source = "user"
    items[0].checked = "true"

    Also the size of both arrays may differ, so only a subset of items in other[] exists. The arrays can get a size of 1500-2000 items each, so a simple for() in a for() is not efficient here i think. (That's why i putted the (!!) behind fast :-) )

    Any ideas, i don't get it
  2. #2  
    If nobody jumps in with an easy answer, I think you may need to back out a bit and consider some refactoring to get all the properties you need into one object.
    It might also help if you post more of the context where these arrays originate, where they're populated, where they're accessed, and where you want to perform this combination. Is your full source available for perusal?
  3. Daemon's Avatar
    796 Posts
    Global Posts
    809 Global Posts
    Sounds like a job for an associative array keyed off 'tag' if it's

    the primary key.

  4.    #4  
    There isn't so much source that i can provide.
    This arrays are both the result of two AJAX Request calls. With the first request i get an array with n-elements like the item[] above.
    In the second request i get the other[] array, i need to combine them to build a list with checkboxes to mark which items of ALL items the user has selected in his profile.
    I read the PrototypeJS documentation for Arrays and Enumeration now, and i think with Array.findAll() could be the right direction, but I'm not sure.

Posting Permissions