Creating nested arrays on the fly

Posted by adardesign on Stack Overflow See other posts from Stack Overflow or by adardesign
Published on 2010-03-18T21:29:44Z Indexed on 2010/03/18 21:41 UTC
Read the original article Hit count: 259

Filed under:
|
|
|

I am trying to do is to loop this HTML and get a nested array of this HTML values that i want to grab.

It might look complex at first but is a simple question...

This script is just part of a Object containing methods.

html

<div class="configureData">
               <div title="Large">
                  <a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
                  <a href="green" title="true" rel="$55.00" name="sku224438"></a>
                  <a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
                </div>
              <div title="Medium">
                  <a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
                  <a href="green" title="true" rel="$55.00" name="sku224438"></a>
                  <a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
                </div>
             <div title="Small">
                  <a href="yellow" title="true" rel="$55.00" name="sku22828"></a>
                  <a href="green" title="true" rel="$55.00" name="sku224438"></a>
                  <a href="Blue" title="true" rel="$55.00" name="sku22222"></a>
             </div>
   </div>

javascript

  // this is part of a script.....  
parseData:function(dH){
 dH.find(".configureData div").each(function(indA, eleA){
                   colorNSize.tempSizeArray[indA] = [eleA.title,[],[],[],[]]
               $(eleZ).find("a").each(function(indB, eleB){
                              colorNSize.tempSizeArray[indA][indB+1] = eleC.title
              })
            })

        },

I expect the end array should look like this.

 [
   ["large", 
      ["yellow", "green", "blue"],
      ["true", "true", "true"],
      ["$55", "$55","$55"]
   ],
   ["Medium", 
      ["yellow", "green", "blue"],
      ["true", "true", "true"],
      ["$55", "$55","$55"]
   ]
 ]
// and so on....

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about arrays