thank you very much for that hint - yes, not very elegant, but it works ...

Andreas


Zitiere Jim Ley <[EMAIL PROTECTED]>:

> 
> "Andreas Neumann" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > > what you can do is:
> > >
> > > a=[]
> > > a['chicken']=whatever
> > > a.push(a['chicken'])
> > >
> > > for (i=0;i<a.length;i++) alert(a)
> >
> > ok, got that - works fine so far. But is there a way, while using
> your
> above
> > described for-loop to get at the same time the key of the associative
> array
> > back, that is corresponding with the value?
> 
> No, you'll have to create objects containing the name value
> 
> a=[]
> a['chicken']={key:'chicken',value:whatever}
> a.push(a['chicken'])
> 
> Then access them with a[0].key / a[0].value - but of course that's
> duplicating stuff.
> 
>  var fruits = new Array();
>  fruits["oranges"] = {key:'oranges',value:25};
>  fruits.push(fruits["oranges"]);
>  fruits["bananas"] = {key:'bananas',value:15};
>  fruits.push(fruits["bananas"]);
>  fruits["pineapples"] = {key:'pineapples',value:8};
>  fruits.push(fruits["pineapples"]);
> 
>  for (i=0;i<fruits.length;i++) {
>     alert(fruits[i].key+','+fruits[i].value);
>  }
> 
> Which is pretty nasty...
> 
> Jim.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



--     
The only thing that stands between a man and what he wants from
life is often merely the will to try it and the faith to believe
that it is possible ...
-- M. DeVos
    
----------------------------------------------     
Andreas Neumann - Department of Cartography     
Swiss Federal Institute of Technology (ETH)     
ETH Hoenggerberg, CH-8093  Zurich, Switzerland     
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153     
e-mail: [EMAIL PROTECTED]     
www: http://www.karto.ethz.ch/neumann/     
SVG.Open/Carto.net: http://www.svgopen.org/     

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to