[EMAIL PROTECTED] wrote:
> Hello i try this to get all values
>
> var elements = $$('[id^="tsum["]');
> for (i in elements)
> {
> alert("The key is "+i+" and the value
> "+elements[i].innerHTML);
> }
>
>
> the fuirst elements all ok but then i get some strange elements having
> undefined values. i thing thats methods of prototype
You should always iterate Array objects using numeric iteration or
Array.prototype iteration. What you're doing is object property
iteration. Array has properties in addition to its members.
// traditional iteration
for (i = 0; i < elements.length; i++) {
alert(
'the id key is ' + parseFloat(elements[i].substring(4)) +
' and the value is " + elements[i].innerHTML
);
}
// Array.prototype iteration (Prototype Enumerable#each)
elements.each(function(element) {
alert(
'the id key is ' + parseFloat(element.substring(4)) +
' and the value is " + element.innerHTML
);
});
- Ken
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---